Javascript 非页面重新加载功能在jQuery中不起作用

Javascript 非页面重新加载功能在jQuery中不起作用,javascript,php,jquery,html,reload,Javascript,Php,Jquery,Html,Reload,不重新加载页面的jQuery代码: $(document).ready(function(){ $('#submit').click(function(){ var page = $(this).attr('id'); $('#content').load('content/submit.php'); }); }); 提交表格 <input class="submit" id="submit"

不重新加载页面的jQuery代码:

       $(document).ready(function(){

         $('#submit').click(function(){
        var page = $(this).attr('id');
        $('#content').load('content/submit.php');
          });
     });
提交表格

<input class="submit" id="submit" name="submit" type="submit" value="Submit">

我不知道在点击提交按钮后是否仍在加载页面,这将帮助您开始一点

您需要通过阻止按钮上的默认事件来阻止正常表单提交。否则,由于表单提交,页面将重新加载

您还需要将数据发送到服务器。您可以使用
serialize()


如何将默认事件放在subbmit按钮上,就像??我已经用
event.preventDefault()
这样做了。这将停止触发表单提交的按钮。让我检查一下,现在提交按钮不工作,没有任何事情发生
<div id="content">
   <h2 style="color:#FF0000;"> Thanks For the Submission </h2> 
</div>
$(function(){
    $('#submit').click(function(event){
           event.preventDefault();
           // collect the form data
           var data = $(this).closest('form').serialize();
            // send the data and load new content
            $('#content').load('content/submit.php', data, function(){
                 // new html now exists can run any code needed here
            });
    });
});