happyhardik
happyhardik

Reputation: 25527

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

Upvotes: 1

Views: 1680

Answers (3)

Abdel Raoof Olakara
Abdel Raoof Olakara

Reputation: 19353

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

Upvotes: 0

Sean Hogan
Sean Hogan

Reputation: 2920

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.

Upvotes: 0

Pekka
Pekka

Reputation: 449425

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?

Upvotes: 5

Related Questions