Jquery.get (URL, [data], [Callback (data, Textstatus, XMLHttpRequest)], [datatype])
Returns:xmlhttprequest
URL string that contains the URL of the request being sent.
The data map or string is sent to the server with the request.
Callback (data, Textstatus, XMLHttpRequest) If the request is successfully executed.
Datatypethe type of data is expected from the server.
This is an abbreviated AJAX feature, which is equivalent to:
$.ajax ({
Url:url,
Data:data,
Success:success,
Datatype:datatype
});
The tuning function successfully returns data passing, which will be an XML root element, a text string, a Web effects file, or a JSON object based on the MIME type of the response. It also passes the response text state.
In jquery 1.4, the successful callback function is also passed through the XMLHttpRequest object.
Most implementations will specify a successful handler:
$.get (' ajax/test.html ', function (data) {
$ ('. Result '). HTML (data);
Alert (' Load was performed. ');
});
This example gets the HTML fragment on the requested page and inserts it.
Additional considerations:
Due to browser security restrictions, most "Ajax" requirements are based on the same Origin policy; Request cannot successfully retrieve data from a different domain, subdomain or protocol.
If a jquery.get () request returns an error code, it will silently fail unless the script also calls the global. Ajaxerror () method.
Script and Jsonp form requests are not limited by the homology policy.
Example:
For example: a Web page that requests a test.php tutorial, but ignores the return result.
$.get ("test.php");
For example, request a test.php page and follow some extra data (while ignoring the return result).
$.get ("test.php", {name: "John", Time: "2pm"});
For example, an array of data is passed to the server (and the return result is ignored).
$.get ("test.php", {' choices[] ': ["Jon", "Susan"]});
For example, alert is the result of the request test.php (HTML or XML, and what is returned).
$.get ("test.php", function (data) {
Alert ("Data loaded:" + data);
});
For example: Alert results from the extra load test.cgi from the same data request (HTML or XML is returned what is different).
$.get ("test.cgi", {name: "John", Time: "2pm"},
function (data) {
Alert ("Data loaded:" + data);
});