首頁  >  文章  >  web前端  >  jquery ajax 簡單範例(介面 後台)_jquery

jquery ajax 簡單範例(介面 後台)_jquery

WBOY
WBOY原創
2016-05-16 17:14:11922瀏覽

介面:

複製程式碼 程式碼如下:

<script> <BR>$() .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 parstring) {
string content = "";
if (par.Equals("ww"))
{
content = "cheng gong le";
}
else
{
content = "shi bai le";
}
return content;
}

陳述:
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn