jquery - How do you return the data from an AJAX success event to the outer function? -


I should have the check_membership () function below to return AJAX "data" However, the "result" is set to the XHR object Is not back, JSON object

How do I fix this?

  function check_membership () {var results; Results = jQuery.ajax ({type: 'post', url: '/ ajax / member', data type: 'jason', async: falls, success: function (data) {return data;}}); Return result;  

}

Thanks.

Javascript will not be '$ wait' for returning to $ .jax success before returning from main function For a callback, then there is a good chance that nothing will be returned to you async option to false (which will block the browser for the duration of the request) or your strategy By modifying a synchronous -Jax call will be used, as you finally get a successful callback of inside The Ahte. For example:

  function update_membership_status () {jQuery.ajax ({type: 'POST', url: '/ ajax / member', datatype: 'jason', success: function (jsn ) {$ ("# Condition"). Text ('Signed in:' + json.SignedIn + Message msg + + json.msg);}}); }  

Comments

Popular posts from this blog

Eclipse CDT variable colors in editor -

AJAX doesn't send POST query -

wpf - Custom Message Box Advice -