用到了jquery的ajax方法,ajax自己写也可以。

具体用法

 

var setId = setInterval(function(){
var xhr = $.ajax({
type: 'HEAD', // 获取头信息,type=HEAD即可
url : window.location.href,
complete: function( xhr,data ){
var date = new Date(xhr.getResponseHeader('Date'))
console.log(date.getFullYear() + '-' + (date.getMonth()+1) + '-' + date.getDate() +' ' + date.getHours() + ':' + date.getMinutes() + ':' + date.getSeconds())
// if(date.getHours()==14 && date.getMinutes()>=0 && date.getSeconds()>=0){
// // clearInterval(setId)
// }
}
})
},1000)

 

ajax生命周期

// 1.ajaxStart(全局事件)
// 2.beforeSend
// 3.ajaxSend(全局事件)
// 4.success
// 5.ajaxSuccess(全局事件)
// 6.error
// 7.ajaxError (全局事件)
// 8.complete
// 9.ajaxComplete(全局事件)
// 10.ajaxStop(全局事件)

 

 



相关文章:

  • 2021-12-26
  • 2021-10-04
  • 2022-12-23
  • 2021-12-28
  • 2022-12-23
  • 2021-06-09
猜你喜欢
  • 2021-12-22
  • 2021-11-10
  • 2022-12-23
  • 2021-11-02
  • 2021-11-29
相关资源
相似解决方案