1 <! Doctype HTML public "-// W3C // dtd xhtml 1.0 transitional // en" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd" >
2 < Html Xmlns = "Http://www.w3.org/1999/xhtml" >
3 < Head >
4 < Meta HTTP-equiv = "Content-Type" Content = "Text/html; charsets = UTF-8" />
5 < Title > Untitled document </ Title >
6 < Script Type = "Text/JavaScript" >
7 VaR XMLHTTP;
8 Function Createxmlhttprequest ()
9 {
10 If (Window. activexobject) // Judge the asynchronous object type of the browser;
11 {
12 XMLHTTP = New Activexobject ( " Microsoft. XMLHTTP " ); // Instantiate an asynchronous object;
13 }
14 Else If (Window. XMLHttpRequest)
15 {
16 XMLHTTP = New XMLHttpRequest ();
17 }
18 }
19 Function Startrequest ()
20 {
21 Createxmlhttprequest (); // Call an asynchronous object;
22 XMLHTTP. onreadystatechange = Function () // Response server call method;
23 {
24 If (XMLHTTP. readystate = 4 ) // Determine whether the request is complete
25 {
26 VaR A = XMLHTTP. responsetext; // Obtain the data returned by the server and assign it to variable.
27 Alert ()
28 }
29 }
30 XMLHTTP. Open ( " Get " , " Admin. php " , True ); // Use the get method to access a server-side URL link script and asynchronously process the creation of a server request
31 XMLHTTP. Send ( Null ); // Send a request;
32 }
33 </ Script >
34 </ Head >
35
36 < Body >
37 < Input Type = "Button" Value = "Submit" Onclick = "Startrequest ()" />
38 </ Body >
39 </ Html >
40
41 Admin. php
42 <? PHP
43 Echo "My name is youyou"
44 ?>
Summary:
1: Judge the browser and instantiate the XMLHTTPRequest object;
2:CodeSegment;
3: Create a request to access the server scripting language through the open method;
4: Send this request using the send method;