javascript - Error shows when reading JSON using JQuery -
dear all, try use jquery read json file disk, simple shows below, shows me error, can't find out why... when check "var jqxhr" in dom, have value of json, when open web page, return error. thank u help
<html> <head> <script src="http://code.jquery.com/jquery-1.5.js"></script> <script> //i check "jqxhr" in dom, have test.json's content, // why there error? .... var jqxhr = $.getjson('test.json', function(data) { alert("success"); var items = []; $.each(data, function(key, val) { items.push('<li id="' + key + '">' + val + '</li>');}); $('<ul/>', { 'class': 'my-new-list', html: items.join('') }).appendto('body'); }) .success(function() { alert("second success"); }) .error(function() { alert("error"); }) .complete(function() { alert("complete"); }); jqxhr.complete(function(){ alert("second complete"); }); </script> </head> <body> </body> </html> test.json: { "one": "singular sensation", "two": "beady little eyes", "three": "little birds pitch doorstep" }
Comments
Post a Comment