如何从javascript中的http get请求获取JSON?网址是:
http://www.streamfinder.com/api/?api_codekey=[devkey]&do=get_genre_list&return_data_format=json
我已经尝试了很多东西,但是似乎都没有用……我已经尝试过了,但是也没有用。
function httpGet(theUrl)
{
var xmlHttp = null;
xmlHttp = new XMLHttpRequest();
xmlHttp.open( "GET", theUrl, false );
xmlHttp.send( null );
return xmlHttp.responseText;
}
问题是我使用的是json而不是jsonp。起作用的代码是这样的:
$.ajax({
url: "URL",
type: 'GET',
dataType: 'jsonp',
success: function(res) {
alert(JSON.stringify(res));
}
});
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句