使用jQuery官方网站提供的例子无法运行,老是报缺少”:” 不知道是什么原因。
Load JSON data using an HTTP GET request.
As of jQuery 1.2, you can load JSON data located on another domain if you specify a
JSONPcallback, which can be done like so: "myurl?callback=?". (The other domain needs to support JSON-P output.) jQuery automatically replaces the ? with the correct method name to call, calling your specified callback. This callback parameter may vary depending on API, for instance Yahoo Pipes requires "_callback=?"
Note: Keep in mind, that lines after this function will be executed before callback.
$.getJSON("http://api.flickr.com/services/feeds/photos_public.gne?tags=cat&tagmode=any&format=json&jsoncallback=?", function(data){ $.each(data.items, function(i,item){ $("<img/>").attr("src", item.media.m).appendTo("#images"); if ( i == 3 ) return false; }); });
所以还是使用老版本的
$.getJSON函数:
function getResult(){ $.getJSON(path,null,function call(data){ flag_sync = data.result; if(flag_sync == true) { $("#waitdiv").hide(); $("#main").show('slow'); }else { setTimeout(function() { getResult() }, interval_getSyncflag); } }); }