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条)

报告相同问题?

悬赏问题

  • ¥15 如何实验stm32主通道和互补通道独立输出
  • ¥30 这是哪个作者做的宝宝起名网站
  • ¥60 版本过低apk如何修改可以兼容新的安卓系统
  • ¥25 由IPR导致的DRIVER_POWER_STATE_FAILURE蓝屏
  • ¥50 有数据,怎么建立模型求影响全要素生产率的因素
  • ¥50 有数据,怎么用matlab求全要素生产率
  • ¥15 TI的insta-spin例程
  • ¥15 完成下列问题完成下列问题
  • ¥15 C#算法问题, 不知道怎么处理这个数据的转换
  • ¥15 YoloV5 第三方库的版本对照问题