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 YoloV5 第三方库的版本对照问题
  • ¥15 请完成下列相关问题!
  • ¥15 drone 推送镜像时候 purge: true 推送完毕后没有删除对应的镜像,手动拷贝到服务器执行结果正确在样才能让指令自动执行成功删除对应镜像,如何解决?
  • ¥15 求daily translation(DT)偏差订正方法的代码
  • ¥15 js调用html页面需要隐藏某个按钮
  • ¥15 ads仿真结果在圆图上是怎么读数的
  • ¥20 Cotex M3的调试和程序执行方式是什么样的?
  • ¥20 java项目连接sqlserver时报ssl相关错误
  • ¥15 一道python难题3
  • ¥15 牛顿斯科特系数表表示