由于你使用的是jQuery,为什么不使用以下内容:
<script language="Javascript"> $(document).ready(function() { $('#YOUR_FORM').submit(function() { // catch the form's submit event $.ajax({ // create an AJAX call... data: $(this).serialize(), // get the form data type: $(this).attr('method'), // GET or POST url: $(this).attr('action'), // the file to call success: function(response) { // on success.. $('#DIV_CONTAINING_FORM').html(response); // update the DIV } }); return false; }); });</script>编辑
正如评论中指出的那样,有时上述方法无效。因此,请尝试以下操作:
<script type="text/javascript"> var frm = $('#FORM-ID'); frm.submit(function () { $.ajax({ type: frm.attr('method'), url: frm.attr('action'), data: frm.serialize(), success: function (data) { $("#SOME-DIV").html(data); }, error: function(data) { $("#MESSAGE-DIV").html("Something went wrong!"); } }); return false; });</script>


