i have the following validate script to run before the form is submitted:
function validateMyForm(){
var numberTo = $('.to').length
$('.to').each(function(){
var product_id = $(this).closest('tr').find('input').get(0).id;
var todate = $(this).val();
var from = $(this).prev().prev().val();
$.ajax({
type: 'POST',
url: myBaseUrl + 'Products/ajax_change_date',
dataType: 'json',
data: {
id: product_id,
todate: todate,
from: from
},
success: function (data) {
numberTo--;
}
});
});
while(numberTo != 0){
}
return true;
}
However when i run this i get a message box in firefox saying its waiting for the script to complete.
How do i avoid that while still keeping the ajax?