SyntaxError: invalid label using jQuery.ajax() -
i'm trying make ajax call server using following jquery call:
$.ajax({ type: "get", datatype: "jsonp", url: "http://iceworld.sls-atl.com/api/&cmd=time", success: function (data) { console.log("success"); console.log(data); }, error: function (error) { console.log("error"); console.log(error); }, });
i data expect browser, firebug keeps saying "syntaxerror: invalid label" shown below:
so, puzzles me reason why error callback called instead of success. i'm wondering did wrong here.
jsonp data must returned in format: callback( jsonobject )
. why getting invalid label
error. expecting function, not json object. need modify server code wrap return value name of callback function. name automatically added request jquery when request jsonp. if watch request, should see this:
http://iceworld.sls-atl.com/api/&cmd=time?callback=jquery191035087670385837555_1365126604422&_=1365126604423
your script needs take callback
parameter , use wrap data, example this:
jquery191035087670385837555_1365126604422({"status":1,"data":"1365126534"})
if accessing server same origin, use json instead.
Comments
Post a Comment