Home >Web Front-end >JS Tutorial >jquery ajax simple example (interface background)_jquery

jquery ajax simple example (interface background)_jquery

WBOY
WBOYOriginal
2016-05-16 17:14:11983browse

Interface:

Copy code The code is as follows:

<script> <br>$(document ).ready(function () { <br>$("#b01").click(function () { <br>htmlobj = $.ajax({ url: "/Content/upFile/test.txt", async: false }); <br>$("#div01").html(htmlobj.responseText); <br>}); <br>}); <br><br>$(document).ready(function () { <br>$("#test").load("/Content/upFile/test2.txt #p1", function (responseTxt, statusTxt, xhr) { <br>if (statusTxt == "success") <br>alert("External content loaded successfully!" 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:" data "nstatus:" 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:" data "nstatus:" status); <br>$("#postText").html(data); <br>} ); <br>}); <br>}); <br><br></script>






After the get method loads the text, it will be displayed here






jquery The load method loads is displayed here


After loading the text, it will be displayed here





The text will be displayed here after loading




< input type="button" value="Load text" id="b01"/>



Backend:
Copy code The code is as follows:

public string getS(string par)
{
string content = "";
if (par.Equals("ww"))
{
content = "cheng gong le";
}
else
{
content = "shi bai le";
}
return content;
}
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn