Description
$.ajax ({type: "post", url: "Handler1.ashx", Data: {username: "admin", Password: "123"},
Success:successhandle});
Function Successhandle (Rep) {
$ ("#msg"). HTML (REP);
}
Tell us more about jquery Ajax examples
Instance
To load a piece of text with Ajax:
jquery Code:
$ (document). Ready (function () {
$ ("#b01"). Click (function () {
Htmlobj=$.ajax ({url: "/jquery/test1.txt", Async:false});
$ ("#mydiv"). HTML (htmlobj.responsetext);
});
});
HTML code:
<div id= "mydiv" ><button id= "B01" type= "button" >change content</button>
jquery Learning uses jquery and prototype consolidation to enable jquery tab to implement local data, using the prototype AJAX approach, now using jquery to achieve the same function, as follows:
jquery is really a very powerful class library, learned today, and fell in love with, talk about the Ajax use of jquery method.
Example:
Test.html
Page reference <script type= "text/web Effects" src= "Jquery-1.3.2.min.js" ></script>
The contents are:
<div id= "divmsg" >hello world!</div>
Usage 1: (Read the remote page content on page load to divmsg)
$ ("#divmsg"). Load (http://localhost:8012/t.asp tutorial, {"Resulttype": "html"});
The return type Resulttype has the following kinds:
"XML", "HTML", "script", "JSON", "Jsonp", "text"
Usage 2: (click Post data to return data)
<input type= "button" id= "Bnajax" value= "Ajax" onclick= "Ajaxtest ()"/>
<script type= "Text/javascript" >
function Ajaxtest ()
{
$.post ("http://localhost:8012/t.asp", {"TXT": "123"},function (data)
{
$ ("#divmsg"). HTML (data);
}
);
}
</script>