<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.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/javascript" src="https://www.jb51.net/js/jquery-1.4.2.min.js"></script>
<script src="https://www.jb51.net/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 runat="server">
<input type="button" value="Show" />
<div>
WebService参数1<input type="text" /><br/>
WebService参数2<input type="text" /><br/>
<input type="button" value="调用Ashx一般处理程序" />
<input type="button" value="调用无参数WebService" />
<input type="button" value="调用有参数WebService" />
<input type="button" value="调用返回集合的WebService" />
<input type="button" value="调用返回复合类型的WebService" />
<input type="button" value="调用返回DataSet的WebService" />
<div></div>
In Dialog!
</div>
</form>
</body>
</html>
jQuery dialog 异步调用ashx,webservice数据的代码
内容版权声明:除非注明,否则皆为本站原创文章。