Ajax Full Contact

Source: Internet
Author: User

Ajax Full-Contact Concept Introduction
    1. Asynchronous:
      1. Refers to the execution of a program does not block other program execution, which is manifested in the order of execution of the program does not depend on the program itself, but rather synchronous. The advantage is that it does not block the execution of the program, thereby improving overall execution efficiency.
    2. The approximate process for implementing Asynchrony:
      1. Use HTML and CSS to implement pages, express information
      2. Asynchronous exchange of data using XMLHttpRequest and Web servers
      3. Use JavaScript to manipulate the DOM for dynamic local refreshes.
    3. http: A rule that enables a computer to communicate over a network.
      1. is a stateless protocol. That is, do not establish persistent links.
    4. The process of the HTTP request:
      1. Establish a TCP connection (TCP: Transmission Control Protocol. A TCP connection is one of the Internet link protocols. Characterized by: orderly and reliable)
      2. Web browser sends request command to Web server
      3. Web browser sends request header information
      4. Web server Answer
      5. Web server sends answer header information
      6. Web server sends data to browser
      7. Web server shuts down TCP connection
    5. An HTTP request typically consists of four parts:
      1. The method or action of an HTTP request, such as a GET or POST request
      2. The URL being requested
      3. The request header, which contains some client environment information, authentication information, etc.
      4. The request body, which is the request body. The request body can contain the query string information submitted by the Customer, form information, and so on.
    6. An HTTP response is typically made up of three parts
      1. A number and text-based status code to show whether the request succeeded or failed
      2. Response header: Contains many useful information like the request header, such as server type, datetime, content type, length, and so on.
      3. Response body: That is, the response body
    7. The difference between a GET request and a POST request:
      1. Get: Generally used for information acquisition, using URL to pass parameters, the number of messages sent is also limited, generally in 2000 characters
      2. POST: Typically used to modify resources on the server, no limit on the number of messages sent
    8. The HTTP status code has a 3-digit number, with the first number defining the type of the status code:
      1. 1XX: Information class, which indicates that a Web browser request is being received and is being processed in one step
      2. 2XX: Success means that user requests are received, understood, and processed correctly. Example: K OK
      3. 3XX: Redirect to indicate that the request has not been successful and that the customer must be able to move further.
      4. 4XX: Client error. Indicates that the client submitted a request with an error. For example: 404 Not Found.
      5. 5XX: Server error, indicating that the server could not complete processing of the request. Example: 500
    9. XMLHttpRequest Relax Request:
      1. Open (method,url,async)
        • method: How to request
        • URL: Requested address (relative or absolute)
        • Async: Asynchronous (Async: TRUE), the default value is true.
      2. Send (String) . The requested content.
        • If a GET request is send (null)
        • If it is a POST request or send (content), the contents are used & spliced
      3. if it is a POST request, also request header setRequestHeader (' Content-type ', ' application/x-www-form-urlencoded ')
    10. XMLHttpRequest Get a response
      1. responseText: Get response data in string form
      2. responseXML: Get response data in XML form
      3. status和statusText: Returns the HTTP status code in numeric and textual form.
      4. getALLResponseHeader(): Get all the response headers
      5. getResponseHeadr(): The value of a field in a query response
      6. readyStateProperty:
        • 0: Request uninitialized, Open has not been called
        • 1: The server connection has been established and open has been called
        • 2: The request has been received, that is to receive the header information
        • 3: The request is processed, that is, the response body is received
        • 4: The request is complete and the response is ready, that is, the response is complete.
        • Can be used to onreadystatechange listen readyState for changes in values.
    11. PHP General Introduction:
      1. PHP is a server-side scripting language that creates dynamic interactive sites.
      2. # # # #php的大致功能:
        • Ability to generate dynamic page content.
        • Ability to create, open, read, write, delete, and close files on the server
        • Ability to receive form data
        • Ability to send and retrieve cookies
        • Ability to add, delete, and modify data in a database
        • Ability to restrict access to certain pages in the site.
        • The basic server language can do all you can.
    12. Json:
      • JavaScript objects notation (JavaScript object Notation)
      • JSON is the syntax for storing and exchanging textual information, similar to XML. He is organized by key-value pairs, easy for people to read and write, and easy to machine parse and generate
      • JSON is language-independent, meaning that JSON can be parsed in any language, simply by following the rules of the JSON.
      • The advantages of JSON versus XML
        • The length of the JSON is shorter than the XML format.
        • JSON reads and writes more quickly
        • JSON can be parsed using JavaScript built-in methods and converted to JavaScript objects, which is very handy.
        • JSON syntax rules
          • The writing format for JSON data is: name/value pairs. Note that the data must be enclosed in double quotation marks.
          • The JSON values can be the following types
            1. Number (integer OR)
            2. String (in double quotes)
            3. Logical value (TRUE or FALSE)
            4. Array (in square brackets)
            5. Object (in curly braces)
            6. Null
        • Implementing Ajax with jquery:
          • Syntax: Jquery.ajax ([Settings])
          • Type: ' POST ' or ' get ', default ' get '
          • URL: Sending the requested address
          • Data: Is an object that is sent to the server, along with the request.
          • DataType: Expected data type returned by the server. If not specified, jquery will automatically be based on the HTTP packet MIME information to intelligently judge, generally we use the JSON format, can be set to ' JSON '
          • Success: is a method that requests a successful callback function. The data after the incoming return, and the string containing the success code
          • Error: is a method that calls this function when a request fails. Incoming XMLHttpRequest Object
        • Cross-domain:
          • The composition of a domain name address:/http/www. Abc.com:8080/scripts/jquery.js
          • (protocol) (subdomain) (primary domain name) (port number) (Request resource address)
          • When any of the protocols, subdomains, primary domain names, or port numbers are different, they are counted as distinct domains
          • Different domains request resources from each other, even if you do ' cross-domain '. For example: http://www.abc.com/index.html request http://www.efg.com/service.php
          • JavaScript is not allowed to invoke objects of other pages across domains for security reasons. What is the cross-domain, simple understanding is because of the JavaScript homologous policy limitations, a.com domain name JS can not operate B.Com or c.a.com the object under the domain name.
          • Note: There can be many subdomains under a primary domain name.
          • Ways to handle cross-domain:
            • Proxy: Create a proxy by using the Web server side of the same domain name.
              • Beijing server (domain name: www.beijing.com) damage Server (domain name: www.shanghai.com)
              • For example, in Beijing's Web server Backstage (www.beijing.com/proxy-shanghaiservice.php) to call the Shanghai server (www.shanghai.com/ service.php) service, and then return the response results to the front end, so that the front-end calls to Beijing with the domain name service is the same as the call to Shanghai service effect.
            • JSONP: A problem that can be used to troubleshoot cross-domain data access for mainstream browsers.
              • In the www.aaa.com page:
        <script>function Jsonp (JSON) {alert (json[' name ']);} </script><script src = ' http://www.bbb.com/jsonp.js ' ></script> jsonp in www.bbb.com page ({' name ': ' Hung Seven ') , ' Age ': 24});
                • Only get requests. Unable to process the POST request.
                • PostMessage solve cross-domain??????
                • Cros
              • XHR2
                • The XMLHttpRequest Level2 provided by HTML5 has implemented cross-domain access and a number of other new features
                • IE10 versions are not supported.
                • On the server side to do some small transformation can:
                  • Header (' access-control-allow-origin:* ');
                  • Header (' Access-control-allow-methods:post,get ');
              

Ajax Full Contact

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.