Veda Sadhak
Veda Sadhak

Reputation: 424

jQuery post error

I am posting data from a form to a PHP page through jQuery.

Below is the code. Let me know if you need to see the code from the php or html pages.

$("#createQuestionForm").submit(function(e) {
    e.preventDefault();
    alert("check1");
    $.post("InsertNewQuestion.php", $("#createQuestionForm").serialize()).done(function(data) {
        alert("check2");
    });
});

I can see the first alert("check1") but the problem is that I cannot see the second alert("check2"). What is the problem?

------------------------------------------AFTER EDIT-------------------------------------------------------------------------

I found the problem: Uncaught TypeError: Object # has no method 'done', how to fix this?

Upvotes: 0

Views: 87

Answers (2)

Veda Sadhak
Veda Sadhak

Reputation: 424

I found the problem. My jQuery file was not up to date. I updated the file and it worked!

Upvotes: 0

user1386320
user1386320

Reputation:

Why don't you re-read the $.post() documentation?:

$.post("InsertNewQuestion.php", $("#createQuestionForm").serialize(), function(data) {
    alert("check2");
}, 'json');

More about the arguments and $.post() options you have on the documentation website.

Upvotes: 1

Related Questions