. NET using jquery and Ajax (iii)-load loading

Source: Internet
Author: User

First create two WebForm pages, one named Default.aspx, to display the load results. One for ajax.aspx, used to be load.

For example, we enter some words or other in ajax.aspx, work hard, Enjoy life~.

Then we introduce jquery into the defaut.aspx and we can start our Ajax load.

First insert a botton and two div in the page, bottom is used to trigger the Load event, the div loads the load page separately and returns the load result.

<input type= "button" value= "Ajaxload" id= "btn"/>

Next we look at the load () function:

Load is the simplest Ajax function, but the use has limitations:

1. It is mainly used to directly return to the HTML Ajax interface

2.load is a jquery wrapper set method that needs to be called on the jquery wrapper set, and the returned HTML is loaded into the object.

Even though the callback function is set, it is undeniable that the load interface is cleverly designed and simple to use. The following example demonstrates the use of the load interface:

Load () function:

Function Description: Load (URL, [data], [callback]) return value: JQuery

Parameter description:

URL: The URL of the HTML page to be loaded in.

Data: (optional parameter) sends the Key/value to the server.

Callback: (optional parameter) The callback function when loading succeeds.

Next, we can write our load JS:

<script type= "Text/javascript" >    $ (document). Ready (function () {        $ ("#btn"). Click (function () {            $ (" #result "). Load (" Ajax.aspx ", Function (Responestext, responsestatus) {                $ (" #display "). Append (" 
In the above JS code, let div id be the return of result ajax.aspx, div ID for display displays the returned text and status

Finally, the running code can produce the result:


At this point, we have successfully implemented the load () method using Ajax.
Next we can use Ajax to add loading animations and so on.

. NET using jquery and Ajax (iii)-load loading

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.