$.ajax ({
Type: "Get",//(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.
URL: "Your url",
timeout:3000,//Set the request time-out (in milliseconds). This setting overrides the global settings.
DataType: ' json ',//
Beforesend:function (XMLHttpRequest) {
You can modify the functions of the XMLHttpRequest object before sending the request, such as adding a custom HTTP header
},
Success:function (data, textstatus) {
The callback function after the request succeeds. This method has two parameters: the server returns data, returns the status
},
Complete:function (XMLHttpRequest, Textstatus) {
The callback function after the request completes (called when the request succeeds or fails).
},
Error:function () {
Request Error Handling
(Default: This method is called when a request for automatic judgment (XML or HTML) fails.) This method has three parameters: the XMLHttpRequest object, the error message, and (possibly) the error object being captured.
Cross-domain
- <script type="Text/javascript" src="jquery.js" ></script>
- <script type="Text/javascript" >
- $.ajax ({
- URL:"http://crossdomain.com/services.php",
- DataType:' Jsonp ',
- Data:",
- JSONP:' callback ',
- Success:function (Result) {
- For (var i in result) {
- Alert (i+":" +result[i]); Loop output a:1,b:2,etc.
- }
- },
- timeout:3000
- });
- </script>
JS Java interaction