您的位置:首页 > Web前端 > JQuery

jquery dialog插件 webservice异步调用代码

2013-09-05 20:23 573 查看
jquery dialog插件 webservice异步调用代码,本款主要是利用jquery +webserver的异步调用代码哦。jquery dialog插件 webservice异步调用代码,本款主要是利用jquery +webserver的异步调用代码哦。
<%@ page language="c#" autoeventwireup="true" codefile="default.asp教程x.cs" inherits="test_jquery_dialog_default" %>
<!doctype html public "-//w3c//dtd xhtml 1.0 transitional//en" "http://www.w3.org/tr/xhtml1/dtd/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>无标题页</title>
</head>
<body>
<script type="text/网页特效" src="网页特效/jquery-1.4.2.min.js"></script>
<script src="js/jquery-ui-1.8.2.custom.min.js" type="text/javascript"></script>
<script type="text/javascript">
$(
function (){
$('#dialog').dialog({
autoopen: false,
width: 600,
buttons: {
"ok": function() {
alert("ok");
$(this).dialog("close");
},
"cancel": function() {
alert("cancel");
$(this).dialog("close");
}
}
});
}
)
function show()
{
$('#dialog').dialog('open');
}
function ajax1()
{
$.ajax({
type:"get",
url:"action/test.ashx",
data:{"time":math.random()},
beforesend:function(xmlhttprequest)
{
},
success:function(msg)
{
alert(msg);
}
});
}
function ajax2()
{
$.ajax({
type:"post",
contenttype: "application/json",
url:"action/webservice.asmx/helloworld",
data:{},
datatype: 'json',
success:function(msg)
{
alert(msg);
}
});
}
function ajax3(setvalue1,setvalue2)
{
if(setvalue1.length==0||setvalue2.length==0)
{
alert('请将两个文本框输入完整!');
return false;
}
$.ajax({
type:"post",
contenttype: "application/json",
url:"action/webservice.asmx/helloa",
data:"{a:'"+setvalue1+"',b:'"+setvalue2+"'}",
datatype: 'json',
success:function(msg)
{
alert(msg);
}
});
}
//返回集合
function ajax4()
{
$.ajax({
type: "post",
contenttype: "application/json",
url: "action/webservice.asmx/getarray",
data: "{'i':'10'}",
success: function(msg) {
alert(msg);
}
});
}
//返回复合类型
function ajax5()
{
$.ajax({
type: "post",
contenttype: "application/json",
url: "action/webservice.asmx/getclass",
data: "{}",
success: function(msg) {
$(msg).each(function() {
alert(msg["id"]+'___'+msg["value"]);
});
}
});
}
//返回dataset
function ajax6()
{
$.ajax({
type: "post",
url: "action/webservice.asmx/getdataset",
data: "{}",
datatype:"xml",
success: function(msg) {
$(msg).find('table1').each(function() {
alert($(this).find("id").text()+'___'+$(this).find("value").text());
});
}
});
}
</script>
<form id="form1" runat="server">
<input id="dialog_link" type="button" value="show" onclick="show()" />
<div id="dialog" style="display: none; background-color: aqua; width: 200px; height: 150px;">
webservice参数1<input type="text" id="txtmsg1" /><br/>
webservice参数2<input type="text" id="txtmsg2" /><br/>
<input type="button" value="调用ashx一般处理程序" onclick="ajax1()" id="btn1" />
<input type="button" value="调用无参数webservice" onclick="ajax2()" id="btn2" />
<input type="button" value="调用有参数webservice" onclick="ajax3(txtmsg1.value,txtmsg2.value)" id="btn3" />
<input type="button" value="调用返回集合的webservice" onclick="ajax4()" id="btn4" />
<input type="button" value="调用返回复合类型的webservice" onclick="ajax5()" id="btn5" />
<input type="button" value="调用返回dataset的webservice" onclick="ajax6()" id="btn6" />
<div id="dictionary"></div>
in dialog!
</div>
</form>
</body>
</html>
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: