本文用到了博客园TerryFeng的例子。 Html,JS代码: 复制代码 代码如下: 无标题页 <BR>$( <BR>function (){ <BR>$('#dialog').dialog({ <BR>autoOpen: false, <BR>width: 600, <BR>buttons: { <BR>"Ok": function() { <BR>alert("OK"); <BR>$(this).dialog("close"); <BR>}, <BR>"Cancel": function() { <BR>alert("Cancel"); <BR>$(this).dialog("close"); <BR>} <BR>} <BR>}); <BR>} <BR>) <BR>function show() <BR>{ <BR>$('#dialog').dialog('open'); <BR>} <BR>function ajax1() <BR>{ <BR>$.ajax({ <BR>type:"get", <BR>url:"action/test.ashx", <BR>data:{"time":Math.random()}, <BR>beforeSend:function(XMLHttpRequest) <BR>{ <BR>}, <BR>success:function(msg) <BR>{ <BR>alert(msg); <BR>} <BR>}); <BR>} <BR>function ajax2() <BR>{ <BR>$.ajax({ <BR>type:"post", <BR>contentType: "application/json", <BR>url:"action/WebService.asmx/HelloWorld", <BR>data:{}, <BR>dataType: 'json', <BR>success:function(msg) <BR>{ <BR>alert(msg); <BR>} <BR>}); <BR>} <BR>function ajax3(setvalue1,setvalue2) <BR>{ <BR>if(setvalue1.length==0||setvalue2.length==0) <BR>{ <BR>alert('请将两个文本框输入完整!'); <BR>return false; <BR>} <BR>$.ajax({ <BR>type:"post", <BR>contentType: "application/json", <BR>url:"action/WebService.asmx/HelloA", <BR>data:"{a:'"+setvalue1+"',b:'"+setvalue2+"'}", <BR>dataType: 'json', <BR>success:function(msg) <BR>{ <BR>alert(msg); <BR>} <BR>}); <BR>} <BR>//返回集合 <BR>function ajax4() <BR>{ <BR>$.ajax({ <BR>type: "post", <BR>contentType: "application/json", <BR>url: "action/WebService.asmx/GetArray", <BR>data: "{'i':'10'}", <BR>success: function(msg) { <BR>alert(msg); <BR>} <BR>}); <BR>} <BR>//返回复合类型 <BR>function ajax5() <BR>{ <BR>$.ajax({ <BR>type: "post", <BR>contentType: "application/json", <BR>url: "action/WebService.asmx/GetClass", <BR>data: "{}", <BR>success: function(msg) { <BR>$(msg).each(function() { <BR>alert(msg["ID"]+'___'+msg["Value"]); <BR>}); <BR>} <BR>}); <BR>} <BR>//返回dataset <BR>function ajax6() <BR>{ <BR>$.ajax({ <BR>type: "post", <BR>url: "action/WebService.asmx/GetDataSet", <BR>data: "{}", <BR>datatype:"xml", <BR>success: function(msg) { <BR>$(msg).find('Table1').each(function() { <BR>alert($(this).find("ID").text()+'___'+$(this).find("Value").text()); <BR>}); <BR>} <BR>}); <BR>} <BR> WebService参数1 WebService参数2 In Dialog! 作者博客:http://www.cnblogs.com/qixuejia/