JS Java interaction

Source: Internet
Author: User

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

  1. <script type="Text/javascript" src="jquery.js" ></script>
  2. <script type="Text/javascript" >
  3. $.ajax ({
  4. URL:"http://crossdomain.com/services.php",
  5. DataType:' Jsonp ',
  6. Data:",
  7. JSONP:' callback ',
  8. Success:function (Result) {
  9. For (var i in result) {
  10. Alert (i+":" +result[i]);   Loop output a:1,b:2,etc.
  11. }
  12. },
  13. timeout:3000
  14. });
  15. </script>

JS Java interaction

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.