I am building a small widget that I am giving to users to emb开发者_如何学运维ed 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. e.g.
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.
精彩评论