Ajax Learning Notes

Source: Internet
Author: User

synchronous vs. asynchronous: When synchronizing, the client submits the request, the user only waits, the server responds, processes, returns data, refreshes the page, asynchronously, when filling in the information, the page can submit the request to the server, the server responds and then processes the request, then returns the result to the page, and the user does not have to wait to know whether the input Correct, while the user can continue to fill in the content without having to refresh and submit the entire page. does not cause clogging. Ajax Process: Use Html+css to implement pages, express information----use XMLHttpRequest and Web server for asynchronous exchange of data------use JavaScript to manipulate the DOM to achieve dynamic local refresh. XMLHttpRequest ObjectOne: var request = new XMLHttpRequest (); Incompatible IE6 and the following two: Var request, if (window. XMLHttpRequest) {request = new XMLHttpRequest ();//ie7+,ff,chrome,opera,safari}else{request = new ActiveXObject ("Mi Crosoft. XMLHTTP "); IE6,IE5} HTTP is a stateless protocol (does not establish a persistent connection)Is the rule that the computer communicates through the network, can make the browser request information and the service to the server, a complete HTTP request process has seven steps: 1, establishes the TCP connection, 2,web the browser sends the request command to the Web server, the 3,web browser sends the request header information; 4, The Web server responds, the 5,web server sends the reply header information, the 6,web server sends the data to the browser, and the 7,web server shuts down the TCP connection.   an HTTP request typically consists of four parts:1,http request method and action, such as Get or POST2, the requested URL3, request header, contains client information, authentication information, etc. 4, request body, contains the request body, the request body can contain client-submitted query string information, form information and so on. Get: Generally used for information acquisition, the use of URL to pass parameters, the number of information sent is limited, generally in 2000 characters, clear text visible, unsafe, idempotent = = = Does not change the number of requests, in this case, can be said to be safe; POST: Typically used to modify resources on the server, The amount of information sent is unlimited, the information in the request body, not visible;   An HTTP response typically has three parts:1, a number and text of a status code to show the success or failure of the request, 2, the response header, and the request header contains a lot of information, such as server type, date and time, content type and length, 3, response body, response body, including the server passed the string and HTML and other content         XMLHttpRequest Sending requests
Open (method sent), URL (requested address), async (whether async, default true, can not fill)) Send (String)---get, parameter is optional, post, required   XMLHttpRequest Get a response
  to know if the response was successful, monitor readystate       JSONJavaScript Object notation is the syntax for storing and exchanging textual information, similar to XML, organized by key-value pairs, easy to read and machine-parsed, JSON is language-independent, and JSON can be parsed in any language, just by the rules of JSON. JSON is shorter in length than XML, read and write faster, and can be easily parsed using JavaScript's built-in method, and converted to JavaScript objects. All JSON key values need to be quoted.   jsonlint check json; JSON parsing with parse, without eval   typically not written in JavaScript native ajax!         cross-Domain     handle cross Domain one: proxy   processing cross-domain two: JSONP: Post is not supported
  dealing with cross-domain three: XHR2
                               

Ajax Learning Notes

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.