what is the problem in this jquery code?
I have the following code that retrive json data and tries to parse it , but it doesn't work . why ?
function News()
{
var q;
if(qN=="" || qN==null)
q="gaza";
else
q=qN;
var txtNews="";
var url='http://api.feedzilla.com/v1/categories/26/articles/search.json?q='+q;
$.getJSON(url,function(json){
alert("te开发者_C百科st");
$.each(json.articles, function(index, elem){
alert(elem[index].author);
});
});
}
So what does it do? I can almost guarantee it doesn't work because you're trying to make a cross-site request. See if the API supports JSONP.
Then try this:
function News()
{
var q;
if(qN=="" || qN==null)
q="gaza";
else
q=qN;
var txtNews="";
var url='http://api.feedzilla.com/v1/categories/26/articles/search.json?q='+q+'&callback=?';
$.getJSON(url,function(json){
alert("test");
$.each(json.articles, function(index, elem){
alert(elem[index].author);
});
});
}
精彩评论