PHP development basic tutorial server response

1. How to get the server response

If you want to get the server's response, you can use the responseText or responseXML attribute of the XMLHttpRequest object.


66.png

##2. responseText attribute

If it comes from the server The response is not XML, use the responseText attribute.

responseText property returns the response as a string, so you can use it like this:

Use 4_1.php to read information from 4_2.txt

4_1. php code

     

AJAX

AJAX

4_2.txt code

* AJAX 是一种用于创建快速动态网页的技术。

3. responseXML attribute

If the response from the server is XML and needs to be parsed as an XML object, please use the responseXML attribute:

Request the 4_4.xml file and parse the response (

In layman's terms, it is in4_3.php page does not refresh to read the response content in 4_4.xml):

4_3.php code

     

AJAX

AJAX

4_4.xml code

   Harry PotterJ K. Rowling 2005 29.99   Everyday Italian Giada De Laurentiis 2005 30.00   Learning XML Erik T. Ray 2003 39.95  XQuery Kick Start James McGovern Per Bothner Kurt Cagle James Linn Vaidyanathan Nagarajan 2003 49.99  
Continuing Learning
||

AJAX

AJAX
submit Reset Code
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!