1

How to post two variables with jQuery AJAX? One variable work fine but two variables not working

function get() {
    $('#age').hide();
    $.post('jrecomment2.php',{ userID: form.userID.value },{ id_number: form.id_number.value }

    function(output){

        $('#age').html(output).slideDown(2000);


        });

}

and the form:

<form name="form" dir="rtl">
    <input type="text" name="userID">
    <input type="text" name="id_number">
    <input type="button" value="submit" style=" width: 120;" onClick="get();"> 

</form>

3 Answers 3

2

You need to use { userID: form.userID.value, id_number: form.id_number.value }.

Sign up to request clarification or add additional context in comments.

1 Comment

Thank you very much
0
$.post('jrecomment2.php',{ userID: form.userID.value, id_number: form.id_number.value }, function(output){ });

Comments

0

you can use this code

 $.ajax({
            type: "POST",
            url: 'jrecomment2.php',
            data: 'userID=' + form.userID.value+'&id_number='+form.id_number.value,
            dataType: 'text',
            async: false,
            cache: false,
            success: function (output) {

            $('#age').html(output).slideDown(2000);
            }
        });

and post method

$.post('jrecomment2.php',{ userID: form.userID.value, id_number:     form.id_number.value }, function(output)
 { 
   $('#age').html(output).slideDown(2000);
 }
);

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.