Home > Web Front-end > JS Tutorial > body text

jquery ajax simple example (interface background)_jquery

WBOY
Release: 2016-05-16 17:14:11
Original
931 people have browsed it

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;
}
Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!