开发者

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);      
        });
    }); 
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜