I have to send some requests from a webpage to the server to register a new user. At the end, when all the request were sent, I reload the page. Problem : if I write this simply :
$.post("first request");
$.post("second request");
$.post("third request");
document.location.href=document.location.href;
The page is reloaded before all the request were sent. What I do right now is :
$.post("$RequestUri.get('UserSetter.setName')",{param:$("#usernamesignup").val()},
function(data)
{
$.post("$RequestUri.get('UserSetter.setCountry')",{param:$("#countrysignup").val()},
function(data1)
{
$.post("$RequestUri.get('UserSetter.addDeliveringCountry')",{param:$("#countrysignup").val()},
function(data2)
{
document.location.href=document.location.href;
});
});
});
Horrible, isn't it? And in the future, I will have to add other requests. How can I do this properly? Thanks a lot.
Niko