Last.fm api和&字符

pas*_*tgt 2 javascript api last.fm

var artist = 'Marina & the Diamonds';
var infourl = 'http://ws.audioscrobbler.com/2.0/?method=artist.getinfo&artist='+artist+'&api_key=xxx&format=json&callback=?';
Run Code Online (Sandbox Code Playgroud)

这是我的javascript代码,我使用infourl进行getJson查询.但正如你所看到的,艺术家变量有一个&角色,而last.fm api正在返回名为Marina的艺术家,而不是Marina&the Diamonds.同时,网址似乎很好:

Request URL:http://ws.audioscrobbler.com/2.0/?method=artist.getinfo&artist=Marina%20&%20the%20Diamonds&api_key=xxx&format=json&callback=jsonp1301591978245
Run Code Online (Sandbox Code Playgroud)

任何的想法?谢谢

ami*_*t_g 5

URL已&编码&.

http://ws.audioscrobbler.com/2.0/?method=artist.getinfo&artist=Marina%20&%20the%20Diamonds&api_key=xxx&format=json&callback=jsonp1301591978245
Run Code Online (Sandbox Code Playgroud)

它应该是%26.

http://ws.audioscrobbler.com/2.0/?method=artist.getinfo&artist=Marina%20%26%20the%20Diamonds&api_key=xxx&format=json&callback=jsonp1301591978245
Run Code Online (Sandbox Code Playgroud)

使用encodeURIComponent("Marina & the Diamonds")编码的查询字符串参数.