Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/69.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 使用jquery submit()方法时,是否有回调来知道提交的页面何时返回?_Javascript_Jquery_Forms_Form Submit - Fatal编程技术网

Javascript 使用jquery submit()方法时,是否有回调来知道提交的页面何时返回?

Javascript 使用jquery submit()方法时,是否有回调来知道提交的页面何时返回?,javascript,jquery,forms,form-submit,Javascript,Jquery,Forms,Form Submit,在我的页面中,我有一个按钮来执行Excel导出 我需要发布一篇文章,以便我可以在服务器中接收数据,因此我正在这样做: var newForm = jQuery('<form>', { 'method': 'post', 'action': targetUrl, 'target': '_top'

在我的页面中,我有一个按钮来执行Excel导出

我需要发布一篇文章,以便我可以在服务器中接收数据,因此我正在这样做:

                    var newForm = jQuery('<form>', {
                        'method': 'post',
                        'action': targetUrl,
                        'target': '_top'
                    }).append(jQuery('<input>', {
                        'name': 'Search',
                        'value': toSearch,
                        'type': 'hidden'
                    }).append(jQuery('<input>', {
                        'name': 'cargaId',
                        'value': $('#CargaId').val(),
                        'type': 'hidden'
                    })));

                    newForm.appendTo('body').submit().remove();
var newForm=jQuery(“”{
'method':'post',
“操作”:targetUrl,
“目标”:“顶部”
}).append(jQuery(“”{
“名称”:“搜索”,
“值”:用于搜索,
“类型”:“隐藏”
}).append(jQuery(“”{
“name”:“cargaId”,
“value”:$(“#CargaId”).val(),
“类型”:“隐藏”
})));
newForm.appendTo('body').submit().remove();
事实上,我需要在页面处理时显示等待的消息,并在页面返回时隐藏消息

有办法吗

谢谢
Jaime

在javascript中,如果不使用ajax或任何其他方法通过javascript发布表单,就无法实现这一点

下面是一个关于如何使用jquery处理表单提交的响应的示例

$('#form').submit(function(){
    $.ajax({
      url: $('#form').attr('action'),
      type: 'POST',
      data : $('#form').serialize(),
      success: function(){
        // Do what you want here. 
      }
    });
    return false;
});