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

推荐订阅源

小众软件
小众软件
B
Blog RSS Feed
美团技术团队
博客园 - 【当耐特】
C
Check Point Blog
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
M
MIT News - Artificial intelligence
aimingoo的专栏
aimingoo的专栏
J
Java Code Geeks
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
Microsoft Azure Blog
Microsoft Azure Blog
博客园 - 司徒正美
T
Tailwind CSS Blog
Last Week in AI
Last Week in AI
Google DeepMind News
Google DeepMind News
D
DataBreaches.Net
人人都是产品经理
人人都是产品经理
N
Netflix TechBlog - Medium
Vercel News
Vercel News
P
Proofpoint News Feed
IT之家
IT之家
I
InfoQ
腾讯CDC
H
Hackread – Cybersecurity News, Data Breaches, AI and More

博客园 - 朱小能

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);
                     }
                 });
                 
             });