jquery Ajax Parameters

Source: Internet
Author: User

 function   Weibo_ajax_send (img) {$.ajax ({ url:thinkphp[ ' MODULE '] + '/topic/publish '  ' POST ' 
    
      '. Weibo_text ' 
     "). Val (), Img:img,}, Beforesend:  
     function () {$ ( ' #loading '). HTML (' Weibo release ... '). dialog (' Open ' 
    

Name of parameter Type Describe
URL (Default: Current page address) send the requested address.
type (default:" Get ") Request method (" POST "or" get "), default to" get ". Note: Other HTTP request methods, such as PUT and DELETE, can also be used, but only some browsers support it.
timeout Set request time-out (milliseconds). This setting overrides the global settings.
async (default: TRUE) by default, all requests are asynchronous requests. If you need to send a synchronization request, set this option to false. Note that the sync request will lock the browser, and the user's other actions must wait for the request to complete before it can be executed.
beforesend The functions of the XMLHttpRequest object can be modified before sending the request, such as adding a custom HTTP header. The XMLHttpRequest object is the only parameter.
 Function (xmlhttprequest) {
This;//the options for this AJAX request}
cache (default: TRUE) JQuery 1.2 new feature, set to False will not load the request information from the browser cache.
complete After the request is complete the callback function (called when the request succeeds or fails). Parameters: XMLHttpRequest Object, Success information string.
 function (XMLHttpRequest, textstatus) {
This;//the options for this AJAX request}
/td>
ContentType String

(Default: "application/x-www-form-urlencoded") the content encoding type when sending information to the server. The default values are suitable for most applications. Tells the server to submit the data format from the browser.

For example, if we use the Json2.js method json.stringify (obj) format as a JSON string when we submit the data, then the default commit will report an error. At this point, you need to specify the content format for the submission: "Application/json".

Data Object,
String

Data sent to the server.

If the data datatype is a JavaScript object or array, jquery automatically calls the Jquery.param () method before committing to encode the data to be sent into the "application/x-www-form-urlencoded" format (i.e. Name=value&name1=value1); JavaScript objects must be in key/value format; If an array, JQuery automatically corresponds to the same name for different values. such as {foo:["bar1", "Bar2"]} converted to ' &foo=bar1&foo=bar2 ';

If the data datatype is of type string, the direct default is that the data has been encoded in "application/x-www-form-urlencoded" format and is no longer converted.

The ProcessData option controls whether conversions are performed. This option defaults to true.

DataType String

The expected data type returned by the server. Set the contents of the "Accept" field in Httpheader, telling the server browser what type of data format to return, and jquery will process the returned data based on that type. If not specified, JQuery automatically returns Responsexml or ResponseText based on the HTTP packet MIME information and is passed as a callback function parameter, with the available values:

" xml ": Returns an XML document that can be processed with jQuery.

"HTML": Returns plain text HTML information, including the script element.

"JSON": Returns the JSON data. jquery automatically translates the returned string format data into JavaScript objects for easy access using the Obj.property format. If this option is not specified, jquery does not automatically convert even if it returns a JSON-formatted string.

"JSONP": jsonp  format. When calling functions using  JSONP , such as "myurl?callback=?" JQuery is automatically replaced? is the correct function name to execute the callback function.

error (default: automatic judgment (XML or HTML)) when a request fails, this method is called. This method has three parameters: the XMLHttpRequest object, the error message, and (possibly) the error object being captured.
 function (XMLHttpRequest, textstatus, Errorthrown) {
//normally textstatus and Errorthown only one of them has a value This The options for this AJAX request}
Global (default: TRUE) triggers global AJAX events. Setting to FALSE will not trigger global AJAX events, such as Ajaxstart or Ajaxstop. Can be used to control different AJAX events
ifmodified (default: false) only gets new data when the server data changes. Use the HTTP packet last-modified header information to determine.
processdata (default: TRUE) by default, the data sent will be converted to an object (technically not a string) to match the default content type" application/ X-www-form-urlencoded ". Set to False if you want to send DOM tree information or other information that you do not want to convert.
success callback function after successful request. This method has two parameters: the server returns data, returns the status
 function (data, textstatus) {
//data could be xmldoc, jsonobj, HTML, text, ET C ... this; The options for this AJAX request}

 

Here are a few Ajax event parameters: Beforesend, Success, complete, error. We can define these events to handle each of our AJAX requests well. Note that the this in these AJAX events is the option information that points to the Ajax request (refer to the picture of this for the Get () method).
Please read the above parameter list carefully, if you want to use jquery for Ajax development, then these parameters you must be familiar with.

jquery Ajax Parameters

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.