在ASP.NET中應(yīng)用Ajax的格式如下:
前臺(tái)代碼(用JQuery庫(kù))
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
|
$.ajax({ type: "POST" , async: true , url: "../Ajax/ajax.ashx" , dataType: "html" , data: null success: function (result) { //do successful sth }, error: function (XMLHttpRequest, textStaus, errThrown) { //do error sth } }) |
Ajax(一般性處理程序)中代碼如下:
1
2
3
4
5
6
|
public void ProcessRequest (HttpContext context) { context.Response.ContentType = "text/plain" ; string result = "Hello World" ; context.Response.Write(result); } |
以上所述是小編給大家介紹的ASP.NET中Ajax使用方法的相關(guān)知識(shí),希望對(duì)大家有所幫助,如果大家想了解更多內(nèi)容,敬請(qǐng)關(guān)注服務(wù)器之家網(wǎng)站!
原文鏈接:http://www.cnblogs.com/ABblog/archive/2016/07/11/5660454.html