jquery ajax post and response evaluation
- by Rami
Hello people,
i am relatively new to javascript and jquery in particular, so please bear with me, i am trying to loop through multiple s and then serialize() the data with jquery and post it using ajax to my page, this's happening alright, and the data is posted, and my php script echos 1 and everything is taken care off, but for some strange reason, the following code is not working, specially the "success" variable, it's not increasing at all! would you please help me?
$('.submitB').click(function(){
var success = 0;
var times = 0;
var alertText;
$('.input').each(function(){
times++;
var serializedForms = $(this).serialize();
$.post('<?=$this->config->site_url()?>crud/additem/forms', serializedForms ,function(data){
if (data)
{
success++;
}
});
});
if (times)
{
alertText = "?? ????? " + success + " ???? ?? ??? " + times + " ?????.";
alert(alertText);
}
})
the Arabic text just says "success + Entries from + times + were entered successfully"..
thank you in advance.