Ajax usage in jquery

Source: Internet
Author: User

Using jquery's Ajax technology, you can easily implement partial page refreshing and backend parameter passing.The basic usage is as follows:

<! Doctype HTML public "-// W3C // dtd xhtml 1.0 transitional // en" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<HTML xmlns = "http://www.w3.org/1999/xhtml">
<Head>
<Meta http-equiv = "Content-Type" content = "text/html; charset = UTF-8"/>
<Title> untitled document </title>
<SCRIPT type = "text/JavaScript" src = "jquery. js"> </SCRIPT>
<SCRIPT>
$ (Function (){
$ ("# Clickme"). Click (function (){
$. Ajax ({
URL: "backend processing page, which can be a page such as PHP/asp/. Net/JSP/Action/or Program ",
Type: "Post ",
Datatype: 'json ',
Data: {Parameter Name: parameter value, parameter name: parameter value ,...},
Success: showresult // note that there is no comma at the end of the last parameter. Success refers to the work to be done on the current page after the background action is completed. It is usually to call another function to report the result to the user.
});
});
})
Function showresult (data) // The parameter data here is used to receive the result returned by the background processing program.
{
$ ("# Result" ).html (data) // asynchronously loads the received feedback results to the elements on the current page.
}
</SCRIPT>

</Head>

<Body>
In this example, after you click the "load content" button, the current page will submit the parameters to the corresponding processing program in the background to receive feedback from the background processing program, and displayed on the current page. The user stays on the current page. <Br/>
<Input type = "button" id = "clickme" value = "load content">
<Div id = "result"> the content is empty. </Div>
</Body>
</Html>

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.