Ajax and ajax Technologies

Source: Internet
Author: User

Ajax and ajax Technologies

AJAX, that isASynchronousJAvascriptANdXMLAllows you to update the page without refreshing the status and submit the page asynchronously.

Advantages:

  • No plug-in support
  • Excellent User Experience
  • Improve Web program performance
  • Reducing the burden on servers and bandwidth

Disadvantages:

  • The forward and backward buttons are damaged.
  • Insufficient support for search engines
  • Lack of development and debugging tools

Synchronous and asynchronous

  • Synchronization: that is, you must do one thing, and wait for the previous one to finish before you can do the next thing.
  • Asynchronous: you do not need to wait until the previous task is finished.

JQuery encapsulates AJAX in three layers

Bottom layer: encapsulates some basic Ajax operations;

    • Global Method: $. ajax ()
      • The submitted data is submitted in data and post. The submitted data must be wrapped in "{}" and submitted in the form of "key: value ".
      • When submitting the entire form, you can use form serialization "serialize ()" to submit the entire form.
      • DecodeURIComponent (): deserialized data
      • EncodeURIComponent (): serializes data. serialize () also calls this method for serialization.
      • SerializeArray (): converts a form to json format.
      • $. AjaxSetup (): initializes the data of $. ajax (), which is used to set the default value of the $. ajax () object.

Layer 2: encapsulates jQuery's Ajax;

    • Local method:. load (url, data, callback)
      • Suitable for asynchronous acquisition of static files
    • Global Method: $. get (url, data, callback, type), $. post (url, data, callback, type)
      • Can be obtained asynchronously with dynamic files

Layer 3: encapsulated get;

    • Global Method: $. getJSON, $. getScript

Load request

$ (Document). ajaxStart (function): Method triggered when a request starts.

$ (Document). ajaxStop (function): Method triggered when the request ends

JSON and JSONP

If dataType is JSON, data cannot be obtained across domains. Add "? Callback =. When dataType is JSONP, cross-domain data can be obtained directly.

JQXHR object

Attributes and methods of the jQuery jqXHR object

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.