Heim  >  Artikel  >  Web-Frontend  >  jquery ajax 简单范例(界面+后台)_jquery

jquery ajax 简单范例(界面+后台)_jquery

WBOY
WBOYOriginal
2016-05-16 17:14:11925Durchsuche

界面:

复制代码 代码如下:

<script> <BR>$(document).ready(function () { <BR>$("#b01").click(function () { <BR>htmlobj = $.ajax({ url: "/Content/upFile/测试.txt", async: false }); <BR>$("#div01").html(htmlobj.responseText); <BR>}); <BR>}); <br><br>$(document).ready(function () { <BR>$("#test").load("/Content/upFile/测试2.txt #p1", function (responseTxt, statusTxt, xhr) { <BR>if (statusTxt == "success") <BR>alert("外部内容加载成功!" + xhr); <BR>if (statusTxt == "error") <BR>alert("Error: " + xhr.status + ": " + xhr.statusText); <BR>}); <BR>}); <br><br>$(document).ready(function () { <BR>$("#getbutton").click(function () { <BR>$.get("/DownSet/index", function (data, status) { <BR>alert("数据:" + data + "\n状态:" + status); <BR>}); <BR>}); <BR>}); <br><br>$(document).ready(function () { <BR>$("#postbutton").click(function () { <BR>$.get("/CustomerInformation/getS", { par: "ww" }, function (data, status) { <BR>alert("数据:" + data + "\n状态:" + status); <BR>$("#postText").html(data); <BR>}); <BR>}); <BR>}); <br><br></script>

post方法加载文本后 会在这里显示






get方法加载文本后 会在这里显示






jquery load方法加载的显示在这里


加载文本后 会在这里显示





加载文本后 会在这里显示







后台:
复制代码 代码如下:

public string getS(string par)
{
string content = "";
if (par.Equals("ww"))
{
content = "cheng gong le";
}
else
{
content = "shi bai le";
}
return content;
}
Stellungnahme:
Der Inhalt dieses Artikels wird freiwillig von Internetnutzern beigesteuert und das Urheberrecht liegt beim ursprünglichen Autor. Diese Website übernimmt keine entsprechende rechtliche Verantwortung. Wenn Sie Inhalte finden, bei denen der Verdacht eines Plagiats oder einer Rechtsverletzung besteht, wenden Sie sich bitte an admin@php.cn