Maison  >  Article  >  interface Web  >  jquery ajax 简单范例(界面+后台)_jquery

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

WBOY
WBOYoriginal
2016-05-16 17:14:11925parcourir

界面:

复制代码 代码如下:

<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;
}
Déclaration:
Le contenu de cet article est volontairement contribué par les internautes et les droits d'auteur appartiennent à l'auteur original. Ce site n'assume aucune responsabilité légale correspondante. Si vous trouvez un contenu suspecté de plagiat ou de contrefaçon, veuillez contacter admin@php.cn