Jquery ajax simple example of of interface + background
- 2020-03-29 23:50:39
- OfStack
Interface:
Background:
<script>
$(document).ready(function () {
$("#b01").click(function () {
htmlobj = $.ajax({ url: "/Content/upFile/ test .txt", async: false });
$("#div01").html(htmlobj.responseText);
});
});
$(document).ready(function () {
$("#test").load("/Content/upFile/ test 2.txt #p1", function (responseTxt, statusTxt, xhr) {
if (statusTxt == "success")
alert(" External content loaded successfully! " + xhr);
if (statusTxt == "error")
alert("Error: " + xhr.status + ": " + xhr.statusText);
});
});
$(document).ready(function () {
$("#getbutton").click(function () {
$.get("/DownSet/index", function (data, status) {
alert(" Data: " + data + "n Status: " + status);
});
});
});
$(document).ready(function () {
$("#postbutton").click(function () {
$.get("/CustomerInformation/getS", { par: "ww" }, function (data, status) {
alert(" Data: " + data + "n Status: " + status);
$("#postText").html(data);
});
});
});
</script>
<div id="div04">
<h2 id="postText">post Method after the text is loaded It will show up here </h2>
<input type="button" value="post Methods to obtain " id="postbutton" />
</div>
<div id="div03">
<h2 id="getText">get Method after the text is loaded It will show up here </h2>
<input type="button" value="get Methods to obtain " id="getbutton" />
</div>
<div id="div02">
<h2>jquery load Method loads are shown here </h2>
<h2 id="test"> After loading the text It will show up here </h2>
</div>
<div id="div01">
<h2> After loading the text It will show up here </h2>
</div>
<p>
<input type="button" value=" Loading text " id="b01"/>
</p>
Background:
public string getS(string par)
{
string content = "";
if (par.Equals("ww"))
{
content = "cheng gong le";
}
else
{
content = "shi bai le";
}
return content;
}