doufu6423 2011-09-19 13:19
浏览 134
已采纳

AJAX表单提交不起作用

I've got a PHP form on index.php that submits through AJAX through submit.php.

Not sure why AJAX isn't working but when I submit the form, the browser just redirects me to submit.php instead of the form DIV in the HTML updating through AJAX.

Here is the index.php code: http://pastebin.com/94QvysMp and the submit.php code: http://pastebin.com/2eJtU8Yw

I think the issue is within the index.php code around about line 39 to 85, but I just can't put my finger on what the issue is why the AJAX isn't working.

Help is appreciated, thanks.

  • 写回答

2条回答 默认 最新

  • dsqdpn31467 2011-09-19 14:17
    关注

    I think your ajax call should be like this:

    ....
    success: function(message) {
        $('#right').html("<div id='submitted'></div>");
        $('#submitted').html(message)
        ....
    

    and in the submit.php file you simply have to echo "Message sent" or "Message not sent", depending on the context. I'm not sure this is the problem, but you could check.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?