0

Is it normal that I have the results in the image when I inspect form data header sent by an ajax call?
What I find strange is that every single character in form data is sent alone. for example there is userName: Sirius and

0: u   
1: s   
2: e   
3: r   
4: N    

and so on...
This is the link. Is it a normal behaviour??

This is my code:

jQuery(function($) {
    jQuery('#wpjob-register').validate({
        rules: {
            userName: {
                required: true,
                minlength: 3
            },
            userPassword: {
                required: true,
                minlength: 1,
            }
        },
        messages: {
            userName: {
                required: "Inserisci una username",
                minlength: "La username deve essere almeno di 3 caratteri"
            },
            userPassword: {
                required: "Inserisci una password",
                minlength: "La password deve essere almeno di 6 caratteri"
            }
        },
        submitHandler: function(form) {
            console.log(jQuery(form).serialize()); //logging for debug!
            jQuery('#wpjob-register .input-submit').css('display','none');
            jQuery('#wpjob-register .submit-loading').css('display','inline-block');
            jQuery(form).ajaxSubmit({
                type: "POST",
                data: jQuery(form).serialize(),
                url: 'http://localhost/wpjob/wp-admin/admin-ajax.php', 
                success: function(data) {
                    if(data == 1) {
                        jQuery("#userName").addClass("error");
                        jQuery(".userNameError").text("Username doesn’t exists. Please try another one.");
                    }

                    if(data == 2) {
                        jQuery("#userPassword").addClass("error");
                        jQuery(".userPasswordError").text("Password doesn’t exists. Please try another one.");
                    }
                },
                error: function(data) {
                    jQuery('#wpjob-register').fadeTo( "slow", 0, function() {
                        jQuery('#error').fadeIn();
                    });
                }
            });
        }
    });
});

Data logging (on the commented line) gives an usual form data content:

userName=dhnbrthy&userPassword=ebthyveyhe&action=wpjobusLoginForm&wpjobusLogin_nonce=14e168813a&_wp_http_referer=%2Fwpjobus%2Flogin%2F&submit=Login   

without all the characters split

Ferex
  • 525
  • 4
  • 21
  • no - this is not normal but it depends on your code which we can't see. Share the code used to generate the json and that processes it – Professor Abronsius Dec 01 '15 at 16:15
  • I didn't include the code because I inherited it. It's a wordpress web-app using the [jQuery validation plugin](https://github.com/jzaefferer/jquery-validation). What could the possible reason to do it? I don't even know how to google for it. – Ferex Dec 01 '15 at 16:19
  • I don't profess to knowing much about jQuery at all but something on this page " http://stackoverflow.com/questions/1960240/jquery-ajax-submit-form " makes me wonder ~ namely "ajaxForm will send when the submit button is pressed. ajaxSubmit sends immediately." – Professor Abronsius Dec 01 '15 at 16:51

0 Answers0