I. load () method (simplest)
Load (url, [data], [callback])
Url: the address of the loaded page.
Data: Optional. data sent to the server. The format is key/value.
Callback: optional, callback function
1. The simplest application
Copy codeThe Code 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> load method application </title>
<Script type = "text/javascript" src = "js/jquery-1.8.2.min.js"> </script>
<Style type = "text/css">
# Divframe {border: 1px solid #999; width: 500px; margin: 0 auto ;}
. LoadTitle {background: # CCC; height: 30px ;}
</Style>
<Script type = "text/javascript">
$ (Function (){
$ ("# Btn"). click (function (){
// Load the entire page
// $ ("# AjaxTip"). load ("paie_a.html ");
// Load an element on the page
$ ("# AjaxTip"). load ("paie_a.html # userinfo ");
})
})
</Script>
</Head>
<Body>
<Div id = "divframe">
<Div class = "loadTitle">
<Input type = "button" value = "Get Data" id = "btn"/>
</Div>
<Div id = "ajaxTip">
</Div>
</Div>
</Body>
</Html>
The code for listing e_a.html is as follows:
Copy codeThe Code is as follows:
<Div id = "userinfo">
Name: Ice Cream <br>
Gender: Tian <br>
Email: 999@123.com
</Div>
Display result:
The button is displayed as follows:
Ii. get () method
Iii. post () method
Iv. ajax () method