开发者

jQuery AJAX, GET, POST JSON issue, getting no response it seems

$.ajax({
type: 'POST',
dataType: 'json',
url: "http://domainsvault.com/test.json",
error: function(){alert('An unexpected Error occured while processing the resquest, reload the page to try again');},
timeout: 7200,
success: function()
{
    document.write('<div style="background:#FFF;color:#000;height:12px;padding:10px" id="info"></div>');
    $.each(data.items, function(i, item)
    {
        //document.write('<img src="'+item.image_url+'" border="0" onClick="alert(\''+item.description+'\')" /><br />');
        document.write('<img src="'+item.image_url+'" border="0" class="imginfo" rel="'+item.description+'" alt="'+item.name+'" />&nbsp;');
    });
}

});

the JSON http://domainsvault.com/test.json

{"items":[{"name":"hamburger","descripti开发者_开发问答on":"A two-patty cheeseburger","image_url":"http://www.rw-designer.com/icon-view/5734.png"},{"name":"hot dog","description":"A hot dog with mustard","image_url":"http://www.rw-designer.com/icon-view/5735.png"},{"name":"pizza","description":"Pepperoni pizza","image_url":"http://www.rw-designer.com/icon-view/5743.png"},{"name":"ice cream","description":"Soft-serve ice cream","image_url":"http://www.rw-designer.com/icon-view/5739.png"},{"name":"fountain drink","description":"Ice cold drink","image_url":"http://www.rw-designer.com/icon-view/5741.png"}]}

Far as I can tell the JSON is valid. The code is working if I hardcode the string it works fine for the $.each(). However attempting to get the JSON from the URI via post or get my response in Firebug is "200 OK" and shows it in red as if the File wasn't found.


Look at the response you are getting.

jQuery AJAX, GET, POST JSON issue, getting no response it seems

http://jsfiddle.net/praveen_prasad/tnaWd/


try using jQuery.getJSON() http://api.jquery.com/jQuery.getJSON/ it can run cross domain

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜