tags:

views:

56

answers:

1

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.

A: 

Do you expect any data to be returned?

It's look like data == null.

Mendy
yes, my php script echos "1" if it's a success or "0" if it messed up, i'm using codeigniter as my framework and this code posted above is in the view, i tried it so many times with different jquery plugins and code that i wrote and it worked, but since i am posting multiple forms "rapidly" i think there might be a problem with jquery "jumping" code blocks? i apologize if i'm not making any sense but i am trying to give the full image
Rami