Ajax Basics (i)

Source: Internet
Author: User

(i) Several methods and properties of the XMLHttpRequest object
Open () creates a new request to the server
Send () sends a request to the server
ReadyState provides current HTTP ready status
Status Server Response state code
Request response text returned by the ResponseText server
ReadyState
0: The request was not issued (before calling open ())
1: The request has been established but has not been issued (before send () is called)
2: The request has been sent out in process (the contents can usually be obtained from the response head)
3: The request has been processed, there are usually some data available in the response, but the server has not completed the response

(ii) Issues to be noted when using XML files for transmission
1. Use post transfer for XML files because the XML file can be very long and the get mode restricts the length of the data transfer
2. Tell the server to send an XML file
3. Send () by sending () and not appended to the last parameter of the URL
(iii) data transfer using JSON
Represents a method name/value pair and an array.
{"Employees": [{"FirstName": "Chen", "LastName": "Li"},{"firstName": "Wang", "LastName": "Xiao"}]}
Creating a JavaScript Object
var company={{"Employees": [{"FirstName": "Chen", "LastName": "Li"},{"firstName": "Wang", "LastName": "Xiao"}]};
Remove first element information
var firstname=company.employees[0].firstname
Modify the first element information
Company.employees[0].firstname= "Ceh"
4: The response is complete, you can access the server response and use it

Related Article

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.