javascript - Cannot access jquery ajax responseText in a deferred object -


I have to create a commitment based on AJAX calls for a web method. Basically, I was working using this method:

  $ Ajax ({url: window.location.pathname + "/ LoadPage"}}. Done (function (data) {// do some stuff}). Failed (function () {// Other things}};   

Then ran on the issue of needing to wait to load before doing something else, so I decided to create a variable to catch the promise object.

 < Code> var promiseObj = $ .ajax ({...});   

Create a named function for calling

  Function Some functions (data) {...}   

Get feedback from server Access

  var someData = promiseObj.responseText;   

and call it

  Promise obz .one (some functions (Some data));   

And it was not working I was getting undefined errors

so I just got to console.log Tried

  console.log (promiseObj) // object console.log (promiseObj. Response text) / / undefinates   

What am I wrong I am doing? How do I send data from AJAX calls to another function using this method? Any help would be appreciated.

First of all, simply delete the bracket in the .done call - just Call .done (some functions) . This will ensure that all parameters generated by AJAX calls have been sent to someFunction . It will also ensure that this reference $ Ajax has passed correctly in the call.

After deciding this, the jqxhr object should be passed as the third parameter of someFunction , so that you .response text .

  function Some functions (data, position, jqXHR) {var text = jqXHR.responseText; ...} promiseObj.done (someFunction);    

Comments

Popular posts from this blog

php - PDO bindParam() fatal error -

logging - How can I log both the Request.InputStream and Response.OutputStream traffic in my ASP.NET MVC3 Application for specific Actions? -

java - Why my included JSP file won't get processed correctly? -