惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

V
Visual Studio Blog
Recent Announcements
Recent Announcements
雷峰网
雷峰网
The GitHub Blog
The GitHub Blog
罗磊的独立博客
月光博客
月光博客
J
Java Code Geeks
A
About on SuperTechFans
Microsoft Security Blog
Microsoft Security Blog
D
Docker
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
F
Fortinet All Blogs
U
Unit 42
C
Check Point Blog
Martin Fowler
Martin Fowler
有赞技术团队
有赞技术团队
博客园 - 叶小钗
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
酷 壳 – CoolShell
酷 壳 – CoolShell
Blog — PlanetScale
Blog — PlanetScale
大猫的无限游戏
大猫的无限游戏
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
阮一峰的网络日志
阮一峰的网络日志
MyScale Blog
MyScale Blog

博客园 - 朱小能

C#对Dictionary的按Value排序 linq to sql中的自动缓存(对象跟踪) 修改域名映射IP地址 SQL 语句,类型转换 hyper-v 网络连接 VS2010 定位文件在solution中的位置 oracle连接字符串配置 spool的简单使用 open数据库Timeout expired 错误 文件的还原与备份 - 朱小能 - 博客园 ASCII码,对应e.KeyChar C# 调用计算器,日历 - 朱小能 - 博客园 Excel 如何由一个文本算术公式得到一个结果 Word、Excel中输入当前日期及时间的快捷键 c# ToString 格式化数字 - 朱小能 GridView绑定 获取access中表的相关信息 Filelog - 朱小能 - 博客园 List<T> 排序 - 朱小能 - 博客园
javascript 调用webservice 的几种方法
朱小能 · 2013-03-04 · via 博客园 - 朱小能

1.

         Sys.Net.WebServiceProxy.invoke(
                          'WebService Path',//Service路径
                          'IsSubmitByURL',//调用方法
                          true,//是否使用HttpGet
                          {'name':name},//参数
                          Onsucceeded,//OnSucceeded时回调函数
                          null,//OnFailed时回调函数
                          null,//UserContext
                          5000//TimeOut
                          );

         function Onsucceeded(){ //todo}

         http://technet.microsoft.com/zh-cn/library/bb383814(es-es).aspx

2.

          xmlhttp=null;
                          if (window.XMLHttpRequest)
                          {// code for all new browsers
                          xmlhttp=new XMLHttpRequest();
                          }
                          else if (window.ActiveXObject)
                          {// code for IE5 and IE6
                          xmlhttp=new ActiveXObject('Microsoft.XMLHTTP');
                          }
                          if (xmlhttp!=null)
                          {
                          
                          var path =  '/DoWork?name='+ encodeURI(name); //webservice路径
                          xmlhttp.open('GET',path,false);  //false同步,true异步
                          xmlhttp.setRequestHeader('Content-Type','application/json; charset=utf-8');
                          xmlhttp.send(null);
                          //alert('xmlhttp.responseXML:'+xmlhttp.responseText);
                          result= xmlhttp.responseText;  //返回结果
                          }
                          else
                          {
                          alert('Your browser does not support XMLHTTP.');
                          } 

3.

 $("#btnClick").click(function() {
                 $.ajax({
                      url:"http://localhost:10168/WebService1.asmx/HelloWorld",
                      beforeSend: function(x) { 
                       x.setRequestHeader("Content-Type", "application/json; charset=utf-8"); 
                     },

       async: false,
                   data: "{code:'"+Code+"'}",

                     dataType:"json",
                     type:"POST",
                     error: function(x, e) { 
                   alert(x.responseText); 
                 }, 
          complete: function(x) { 
                       //alert(x.responseText); 
                 } ,
                     success:function(data){
                        var msg=data.d;
                      var json=JSON2.parse(msg);
                        alert(json.id);
                     }
                 });
                 
             });