Page reload after all Ajax calls
Hello all,
For each input property in the form, i need to post the values using an Ajax call.
after all the ajax call is completed, the page needs to be reloaded.
Since Ajax is a asynchronous call, the page gets reloaded even before all inputs are posted.
How can i ensure the the location.reload() is executed only after all input elements of the forms are posted?
Appreciate any advise.
- function postValues() {
- $(".dynamicform :input").each(function() {
- postPropertyValues($(this).attr("id"));
- }
- );
- location.reload();
- }
- function postPropertyValues(name) {
- var data = $(name).val();
- $.ajax({
- type: "POST",
- url: url,
- data: data,
- }).done(function(){
- console.log("Posted Property Name: "+name + "\tValue: "+data);
- }) ;
-
- }