I would like to get the url from a jQuery success function, after it retreives data from the server. Unfortunately, the three parameters the success function takes don't expose the original url:
success: function(data, statusText, jqhxr)
I dumped the jqhxr variable, and couldn't find the url in there. The reason I need the url is because I'm making several calls at once through a loop, and therefore I have no idea which Ajax call is coming back. Making it an asynchronous call didn't help either.
Thank you in advance!
this.url
inside success function will work because this
refers to the current context of the function, and since the success function is part of the settings object that you're passing to .ajax()
it will access the url property.
See an article describing js scope and .ajax().
you mean making it a synchronous call didn't help...?
and my suggestion would be to set a parameter in the data you're getting back to determine what to do with it, if you're looping through a bunch of AJAX calls. But really you should have to loop through more than one call if you're doing it right you should be able to send enough parameters along with the data to get it all back in one call, this reduces the number trips between client and server, server and database, then server back to client.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With