Cross-origin request JSONP 2

Source: Internet
Author: User


Part 1: Add two practical functions

1. added the data attribute and request parameters.
2. added the scope attribute so that the callback function can be executed in the specified context.

 

The interface is as follows:

View sourceprint? 1 Sjax. load (url ,{

2 data // request parameter (key-Value Pair string or js object)

3 success // callback function after successful

4 scope // callback function execution Context

5 timestamp // whether to add a timestamp

6 });

 

Example

View sourceprint? 01 <! Doctype html>

02

03

04 <meta charset = "UTF-8">

05 <title> sjax_0.2.js by snandy </title>

06 <script src ="Http://files.cnblogs.com/snandy/sjax_0.2.js> </script>

07

08 <body>

09 <input type = "button" value = "Get Name" onclick = "clk ()"/>

10 <script type = "text/javascript">

11 function clk (){

12 Sjax. load (http://files.cnblogs.com/snandy/jsonp.js ,{

13 fn: function () {alert (jsonp. name )},

14 data: {a: 1, B: 2, c: [11,22]},

15 timestamp: true

16 });

17}

18 </script>

19 </body>

20

Related Article

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.