加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

Ajax 获取服务器时间

发布时间:2020-12-16 02:02:47 所属栏目:百科 来源:网络整理
导读:转自:http://www.jb51.cc/article/p-agpzymln-g.html [html] view plain copy html xmlns = "http://www.w3.org/1999/xhtml" head title / script src = "js/Jquery1.7.js" type = "text/javascript" script script type = "text/javascript" $(function(){

转自:http://www.52php.cn/article/p-agpzymln-g.html


[html] view plain copy
  1. <htmlxmlns="http://www.w3.org/1999/xhtml">
  2. head>
  3. title></scriptsrc="js/Jquery1.7.js"type="text/javascript"scriptscripttype="text/javascript" $(function(){
  4. /*$('#Button1').click(function(){
  5. $.ajax({
  6. type:"post",
  7. contentType:"application/json",
  8. url:"WebService1.asmx/GetDate",248); line-height:18px; margin:0px!important; padding:0px 3px 0px 10px!important"> data:"{}",108); list-style:decimal-leading-zero outside; color:inherit; line-height:18px; margin:0px!important; padding:0px 3px 0px 10px!important"> success:function(result){
  9. $('#mydiv').text(result.d);
  10. }
  11. })
  12. })*/
  13. functionGetDate(){
  14. $.ajax({
  15. type:"post",//客户端向服务器发送请求时采取的方式
  16. contentType:"application/json",//指定客户端发送给服务器的内容的类型以及服务器返回给客户端内容的类型为json格式
  17. url:"WebService1.asmx/GetDate",//指明客户端要向哪个页面里面的哪个方法发送请求
  18. data:"{}",//指定伴随发送的请求传递到服务器的参数
  19. success:function(result){//客户端调用服务器端方法成功后执行的回调函数。
  20. $('#mydiv').text(result.d);
  21. }
  22. })
  23. setInterval(GetDate,1000);
  24. bodydivid="mydiv"divinputid="Button1"type="button"value="获取服务器时间"/>
  25. html>

解决使用ajax没反应的问题
1.在后台设置断点,调试,看看能否触发后台方法
2.如果能够触发,说明前台的ajax代码写的没问题
3.如果不能触发,说明ajax代码有问题,着重检查url,data两个参数。

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读