开发者

Javascript Widget JSONP

I am looking to create a widget similar to the one created by Get Satisfaction (http://getsatisfaction.com/). You can see their widget by clicking on 'Feedback' on the left side of the page.

We would like the user to be setup by cop开发者_StackOverflowying a bit of JS to their webpage and nothing else.

In its simplest use, a user would open the widget and enter data. This data would be sent to our server (cross domain) for processing and a response sent back to the user.

Can anyone shed some light on how this can be done?

I've read that I can send a JSONP request using jQuery and handle a response callback- can this be encapsulated with injected javascript?

All help greatly welcome.

Regards


You are correct, JSONP is the correct method for this and should work for your situation. JSONP is basically injecting a <script> tag to simulate a GET response, the contents of the script is a callback method with the JSON object inside it. Hense the name, JSON + Padding.

Note: JSONP does obviously not support POST callbacks or custom headers, as it is just a <script> tag that gets injected and removed when ready.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜