日本搞逼视频_黄色一级片免费在线观看_色99久久_性明星video另类hd_欧美77_综合在线视频

國內(nèi)最全I(xiàn)T社區(qū)平臺 聯(lián)系我們 | 收藏本站
阿里云優(yōu)惠2
您當(dāng)前位置:首頁 > web前端 > jquery > jQuery dialog 異步調(diào)用ashx,webservice數(shù)據(jù)

jQuery dialog 異步調(diào)用ashx,webservice數(shù)據(jù)

來源:程序員人生   發(fā)布時間:2014-05-28 18:48:11 閱讀次數(shù):3141次

jQuery dialog 異步調(diào)用ashx,webservice數(shù)據(jù)

點(diǎn)擊按鈕,在彈出的jQuery.dialog中,顯示異步返回的數(shù)據(jù)。

WebService可以寫復(fù)雜的函數(shù),ashx可以根據(jù)傳過來的參數(shù)調(diào)用不同的方法,達(dá)到同樣的效果。

本文用到了博客園TerryFeng的例子。

Html,JS代碼:

代碼
<%@ 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>無標(biāo)題頁</title>
</head>
<body>

<script type="text/javascript" src="js/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);
}
});
}

//返回復(fù)合類型
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參數(shù)1<input type="text" id="txtMsg1" /><br/>
WebService參數(shù)2<input type="text" id="txtMsg2" /><br/>
<input type="button" value="調(diào)用Ashx一般處理程序" onclick="ajax1()" id="btn1" />
<input type="button" value="調(diào)用無參數(shù)WebService" onclick="ajax2()" id="btn2" />
<input type="button" value="調(diào)用有參數(shù)WebService" onclick="ajax3(txtMsg1.value,txtMsg2.value)" id="btn3" />
<input type="button" value="調(diào)用返回集合的WebService" onclick="ajax4()" id="btn4" />
<input type="button" value="調(diào)用返回復(fù)合類型的WebService" onclick="ajax5()" id="btn5" />
<input type="button" value="調(diào)用返回DataSet的WebService" onclick="ajax6()" id="btn6" />
<div id="dictionary"></div>
In Dialog!
</div>
</form>
</body>
</html>

Ashx代碼:

<%@ WebHandler Language="C#" Class="test" %>

using System;
using System.Web;

public class test : IHttpHandler {

public void ProcessRequest (HttpContext context) {
context.Response.ContentType = "text/plain";
context.Response.Write("Hello A");
context.Response.End();
}

public bool IsReusable {
get {
return false;
}
}

}

WebService:

using System;
using System.Collections;
using System.Web;
using System.Web.Services;
using System.Web.Services.Protocols;
using System.Collections.Generic;
using System.Data;

/// <summary>
///WebService 的摘要說明
/// </summary>
[WebService(Namespace = "http://abc.com/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
[System.Web.Script.Services.ScriptService]

public class WebService : System.Web.Services.WebService
{

public WebService()
{

//如果使用設(shè)計的組件,請取消注釋以下行
//InitializeComponent();
}

[WebMethod]
public string HelloWorld()
{
return "Hello C";
}

[WebMethod]
public string HelloA(string a, string b)
{
return "Hello__" + a + "__" + b;
}

[WebMethod]
public List<int> GetArray(int i)
{
List<int> list = new List<int>();

while (i >= 0)
{
list.Add(i--);
}

return list;
}

[WebMethod]
public Class1 GetClass()
{
Class1 cl=new Class1();
cl.ID="qixuejia";
cl.Value="qixuejia.cnblogs.com";
return cl;

}

[WebMethod]
public DataSet GetDataSet()
{
DataSet ds = new DataSet();
DataTable dt = new DataTable();
dt.Columns.Add("ID", Type.GetType("System.String"));
dt.Columns.Add("Value", Type.GetType("System.String"));
DataRow dr = dt.NewRow();
dr["ID"] = "1";
dr["Value"] = "qixuejia.cnblogs.com";
dt.Rows.Add(dr);
dr = dt.NewRow();
dr["ID"] = "2";
dr["Value"] = "qixuejia";
dt.Rows.Add(dr);
ds.Tables.Add(dt);
return ds;
}

}
public class Class1
{

private string _ID;
private string _Value;

public string ID
{
get { return _ID; }
set { _ID = value; }
}
public string Value
{
get { return _Value; }
set { _Value = value; }
}
}

出處:http://www.cnblogs.com/qixuejia

生活不易,碼農(nóng)辛苦
如果您覺得本網(wǎng)站對您的學(xué)習(xí)有所幫助,可以手機(jī)掃描二維碼進(jìn)行捐贈
程序員人生
------分隔線----------------------------
分享到:
------分隔線----------------------------
關(guān)閉
程序員人生
主站蜘蛛池模板: 精品国产乱码久久久久久影片 | 国产精品免费电影 | 黄色大片www | av毛片| 久久伊人精品视频 | 日韩欧美国产高清 | h片在线观看视频免费免费 日韩国产一区二区 | 国产一区二区三区免费视频 | 亚洲一区二区中文字幕 | 国产一区二区免费网站 | 国内精品久久久久久 | 精品小视频| 日韩中文字幕在线视频 | 婷婷av在线 | 久久免费影院 | 性欧美日本 | 在线久热 | 丁香婷婷综合激情五月色 | 99精品免费久久 | 亚洲国产精品自拍 | 在线观看视频一区 | 亚洲精品卡一 | 美女一级黄色毛片 | 国产精品久久久久久婷婷天堂 | 欧美精品一区二区三区视频 | 中文字幕在线不卡视频 | 成人免费视频在线看 | 国产尤物av | 国产视频一区在线观看 | 成人精品国产免费网站 | 国产九色 | 日韩成人三级 | 97福利电影 | aaa日本高清在线播放免费观看 | 国产精品一区二区三区在线免费观看 | 极品久久| 最新的中文字幕 | 国产精品igao视频网网址不卡日韩 | 国产乱人伦 | 精品久久精品久久 | 自拍欧美日韩 |