I have a simple question regarding multiple ajax calls, performing each call in sequence. I have a button that posts the current page’s form (which will write the form values into session), then I want to call another page (GET) after these session variables are set.
The problem is, I run both calls in a function and if the first post does not make it through in time, the session values are not present on the other script which are required.
Here’s my button’s function:
function generateFP() {
$.post("test.php", $("#webcto_form").serialize());
loadPage('getpage.php?page=fpreq','page_contents');
}
And my loadPage function:
function loadPage(filename,id){
$("#page_contents").load(filename);
}
Is it possible to use the shorthand ajax ($.post/.load) in conjunction with a success? I want to change my generateFP to call the loadPage function after successfully submitting the form.
I’ve seen standard $.ajax documentation explaining how to build a success function but have not yet found any information using the syntax that I am using.
This should work for you. You will be calling the loadPage function in a success event handler function.