显示“进行中"在javascript/jquery/php中执行http请求(长时间运行)期间 [英] Show "In Progress" during http request (long running) execution in javascript/jquery/php
问题描述
我希望在常规http请求期间收到正在加载.."/正在执行.."消息.仅应在http请求周期中显示此内容,并且一旦完成请求并获得响应,它就应该关闭.我热衷于常规HTTP请求和HTTP请求,这些请求会花费更长的时间而不是AJAX.代码块,示例,指针表示赞赏.这是一种方法,我想采用通用方法,以便可以将其用于任何http请求.
I would like to have "Loading.." / "In Progress.." message during regular http request. This should be shown only during the http request cycle, and once you get the request is completed and you get the response, it should go off. I am keen about regular HTTP Request, and HTTP Request that take longer time and not AJAX. Code blocks, examples, pointers appreciated. Here is one approach, I would like to have common approach, so that it can be used for any http request.
推荐答案
您应该使用beforeSend和complete事件:
You should use beforeSend and complete events:
$.ajax({
...
beforeSend: function(){
//Here you loading SHOW
},
complete: function(){
//Here you loading HIDE
}
...
});
这篇关于显示“进行中"在javascript/jquery/php中执行http请求(长时间运行)期间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!