开发者

AJAX form submission doesn't work

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.


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.


Add this (first line below is on line 40 on pastebin)

$(document).ready(function(){
        $("form#register").submit(function(e){ 
            e.preventDefault;
            ... Rest of code stays the same
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜