A summary of Get request methods in JQuery Ajax

Source: Internet
Author: User
Tags getscript

$.get () defination and Usage

Retrieving data from the server in HTTP GET mode

Examples

Request test.php, but ignore the returned data

$.get ("test.php");

Request test.php and send additional data as requested (ignoring returned results)

$.get ("test.php", {name: "Donald", Town: "Ducktown"});

Request test.php and Pass array data to the server (ignoring returned results)

$.get ("test.php", { ' colors[] ': ["Red", "Green", "Blue"] });

Request test.php and return the contents of alert output

function (data) {  alert ("data:" + data);});
Syntax
$.get (Url,data,function(DATA,STATUS,XHR), DataType)

Parameter Description
Url Must specify the URL address that you want to request
Data Optional, data sent to the server along with the request
function (DATA,STATUS,XHR) Optional, function that is called when the request succeeds
Additional Parameters:
  • Data-The results of the request returned
  • Status-the state of the request ("Success", "Notmodified", "Error", "timeout", or "ParserError")
  • xhr -Contains XMLHttpRequest objects
DataType Optionally, specify the type of data the server wants to return
Default jquery for automatic guessing
Possible types of P:
  • "XML"-an XML document
  • "HTML"-HTML as plain text
  • "Text"-a plain text string
  • "Script"-runs response as JavaScript and returns as normal text
  • "JSON"-runs response as JSON and returns a JavaScript object
  • "Jsonp"-uses JSONP to load in the JSON block, adding "? callback=?" to the URL to specify the callback function callback
$.getjson ()

The Getjson () uses an AJAX HTTP GET request to get the JSON.

$ (selector). Getjson (Url,data,success (DATA,STATUS,XHR))
$.getscript ()

The GetScript () uses AJAX HTTP get to get and specify a JavaScript

$ (selector). GetScript (Url,success (response,status))

Parameter Description
wr. The URL address that must be sent for the request
Success (Response,status) Optional, specifying a callback function after a successful run
  • Response -Contains the result data returned from the request
  • Status-contains the requested State ("Success", "Notmodified", "Error", "timeout", or "ParserError")

A summary of Get request methods in JQuery Ajax

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.