Sign In| Join
Get Help:Ask a Question in our Forums|Report a Bug|More Help Resources
Last post Jun 01, 2012 07:09 AM by blurearc
Member
169 Points
313 Posts
May 31, 2012 10:09 PM|LINK
Within an $.ajax call, is it possible to make another $.ajax call on success like so?
$(function(){ $.ajax( { url: "path/to/url", success: function(data){ $.ajax( {
url: "path/to/another/url", success:
function(msg)
{
$("#mydiv").html(msg);
} }); }, } ) });
I did a quick test, but it wasn't successful. I guess I have to return all the data I need in one $.ajax call. Can anyone share some thoughts on this? Thank you.
All-Star
137692 Points
22152 Posts
Moderator
MVP
May 31, 2012 11:19 PM|LINK
yes,it;s possible. I have done many times. Just put error handler for jquery like here
http://bit.ly/mvc_ajax_jquery
Contributor
3710 Points
692 Posts
Jun 01, 2012 07:09 AM|LINK
Yes it is really possible. But does it really required, as I believe that you want to have back-to back ajax call...
second ajax call on the success/error of first
but if you do it logically you can do that in the same POSt.
What is you exact requirment.
antonyliu200...
Member
169 Points
313 Posts
Possible call .ajax on success?
May 31, 2012 10:09 PM|LINK
Within an $.ajax call, is it possible to make another $.ajax call on success like so?
$(function(){ $.ajax( { url: "path/to/url", success: function(data){ $.ajax( {{$("#mydiv").html(msg);} }); }, } ) });I did a quick test, but it wasn't successful. I guess I have to return all the data I need in one $.ajax call. Can anyone share some thoughts on this? Thank you.
ignatandrei
All-Star
137692 Points
22152 Posts
Moderator
MVP
Re: Possible call .ajax on success?
May 31, 2012 11:19 PM|LINK
yes,it;s possible. I have done many times. Just put error handler for jquery like here
http://bit.ly/mvc_ajax_jquery
blurearc
Contributor
3710 Points
692 Posts
Re: Possible call .ajax on success?
Jun 01, 2012 07:09 AM|LINK
Yes it is really possible. But does it really required, as I believe that you want to have back-to back ajax call...
second ajax call on the success/error of first
but if you do it logically you can do that in the same POSt.
What is you exact requirment.
"There are NO shortcuts for success, better stop taking one."
Ravi Kant Srivastava