I'm using jQuery 1.9.1 which is doing JSONP against ESSI API. There is a normal routine below to call in the API; It accepts a signed request (URL), a JSNP callback name and an error handler. ($ Url: signOAuthRequest, type: "GET", data type: "jsonp", jsonpCallback: callback, jsonp: ( Usage: And it works In the error handler, the status code is 200 and the error message is Why is this error being thrown on an otherwise successful call? Based on the comments and what is in your question, I will write that code: / P> I made the following changes: An additional parameter was added to pass a successful callback. This is necessary because jQuery will define callback for you so that it receives a successful response and it can pars. Extracted removed Success has not passed: successFn so that jQuery CallbackName is renamed Callback so that it is more clear about what it does. If you make an alternative solution, you still insist on defining callback, you have to use the script datatype (taken from the comment below)
call ("http: //the.api/? Signrequest", "myCallback", myErrorHandler);
myCallback Fire, getting Jason object looks good Everything is OK.
"parsererror" . The error
"myClall was not called" The thing is that,
myCallback was called definitely and it was The JSN object passed was properly parsed, so I did not find it at all.
function (signed oathurum, callback name, successfanes, error) {$. Axx ({url: Signed Ohah Request, Type: "Received", Data Type: "JSONP", jsonpCallback: callbackName, jsonp: false, cache: true, success: successFn, error: function (jqXHR, textStatus, errorThrown ) {If (typeof errorFn == 'undefined') {errorFn (jqXHR, textStatus, errorThrown);}}}); }
crossdomain:. True because it is unnecessary
proccessData: false because it does not affect jsonp requests and you added any data
successFn will execute with pars on success with json data.
$ Ajax ({Url: signedOAuthRequest, datatype: "script", cache: true});
No comments:
Post a Comment