Jquery Ajax beginner

Source: Internet
Author: User

<SCRIPT type = "text/JavaScript">
$ (Function ()
{

$ ("# Btnajaxget"). Click (function (Event)
{

// Send a GET request
$ ("# Divresult"). Load ("../data/ajaxgetmethod. aspx? Param = btnajaxget_click "+" & timestamp = "+ (new date (). gettime ());
});

$ ("# Btnajaxpost"). Click (function (Event)
{
// Send a POST request
$ ("# Divresult"). Load ("../data/ajaxgetmethod. aspx", {"Param": "btnajaxpost_click "});
});

$ ("# Btnajaxcallback"). Click (function (Event)
{
// Send a POST request, and then execute the callback function.
$ ("# Divresult"). Load (".../data/ajaxgetmethod. aspx", {"Param": "btnajaxcallback_click"}, function (responsetext, textstatus, XMLHttpRequest)
{
Responsetext = "add in the callback function! <Br/> "+ responsetext
$ ("# Divresult" ).html (responsetext); // or: Response (this).html (responsetext );
});
});

$ ("# Btnajaxfilthtml"). Click (function (Event)
{
// Send a GET request and filter out the "Anshan" item from the result
$ ("# Divresult"). Load ("../data/ajaxgetcityinfo. aspx? Resulttype = html "+" & timestamp = "+ (new date (). gettime () +" Ul> Li: Not (: Contains ('anshan '))");
});

})
</SCRIPT>

------------------------------------

$ ("# Button1"). Click (function (){
$ ("# Divresult"). Load ($ ("# divresult"). Load ("/demo/ajaxgetmethod. aspx", {"Param": "button#click "});
})

------------------

Function del (OA ){
VaR $ OTR = $ (OA). Parent (). Parent ();
Var key = $ OTR. ATTR ("key ");
If (confirm ("are you sure you want to delete this record? ")){
$. Getjson ("ajaxdeluserinfo. aspx", {ID: Key}, function (data ){
If (data. Success ){
$ OTR. Remove ();
} Else {
Alert (data. errormessage );
}
})
}
}

----------------------------

Protected void page_load (Object sender, eventargs E)
{
If (request ["ID"]! = NULL)
{
Int id = int. parse (request. querystring ["ID"]);
Try
{
Bll. authormanager. deleteauthorbyid (ID );
Response. Write ("{success: True, errormessage :''}");
}
Catch
{
Response. Write ("{success: false, errormessage: 'deletion error! '}");
}
}

}

==============================

Login

$ ("# Btnlogin"). Click (function (){
// Var Params = $ ("# form1"). serialize ();
// Alert (Params );
// $. Ajax (
//{
// Type: "Get ",
// URL: "/demo/loginhandler. aspx ",
// Data: Params,
// Success: function (data ){
// Alert (data );
//}
//})
// $. Get ("/demo/loginhandler. aspx ", {txtuser: $ (" # txtuser "). val (), txtpass: $ ("# txtpass "). val ()}, function (data ){

$. Post ("/demo/loginhandler. aspx ", {txtuser: $ (" # txtuser "). val (), txtpass: $ ("# txtpass "). val ()}, function (data ){
// Data indicates the content returned by the request
Alert (data );
$ ("# Id1" ).html (data );
//});
// $. Getjson ("/demo/loginhandler. aspx ", {txtuser: $ (" # txtuser "). val (), txtpass: $ ("# txtpass "). val ()}, function (josn ){
// Alert (josn. Success );
});

----

Loginhandler. aspx"

Protected void page_load (Object sender, eventargs E)
{
If (request ["txtuser"]! = NULL & request ["txtpass"]! = NULL)
{
String username = request. querystring ["txtuser"];
String Password = request. querystring ["txtpass"];
If (username = "admin" & Password = "123 ")
{
Response. Write ("11111111111"); // {success: true}
}
Else
Response. Write ("22222222222222"); // {success: false}
}
Else
Response. Write ("{success: false }");
}

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.