简体   繁体   中英

javascript cross-domain issue

I am building a small widget that I am giving to users to embed in their websites and blogs. Now the widget loads a javascript file in the page where it is embedded from my server, which in turn puts an xmlhttp request back to my server to obtain data. Due to security reasons this request is being blocked when placed on other server (except my server). I need a solution to this.

I have searched a lot for a solution.

I am sure I cannot use the proxy solution here as the domains on which the script will be running is not controlled by me.

Also, I cannot use iframe due to Search engines.

What could be a possible solution?

Thanks,

happyhardik

To my knowledge, using JSONP is the only way to do this.

Also, I cannot use iframe due to Search engines.

This I don't understand, though: If your widget is JavaScript driven, it won't turn up in any search engines anyway, will it?

This is pretty much a duplicate of any number of related queries. eg

Cross Domain Scripting Issues & JSONP

Basically you want to use JSONP.

EDIT: I see Pekka has already said this.

Browsers do not support cross domain ajax requests due same origin policy . You can check out this javascript library: ACD .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM