Ajax 获取服务器时间

前端之家收集整理的这篇文章主要介绍了Ajax 获取服务器时间前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

转自:http://www.jb51.cc/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. @H_404_175@bodydivid="mydiv"divinputid="Button1"type="button"value="获取服务器时间"/> @H_404_175@html>

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

猜你在找的Ajax相关文章