$.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