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 statusFinally, 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