Cross domain problem

30 views
Skip to first unread message

alexnald...@hotmail.com

unread,
Oct 10, 2006, 10:17:32 AM10/10/06
to Jayrock
Hi,

I have two domains ( www.example1.com and www.example2.com from
diferent servers )

example2.com have a page with this tag

<script type="text/javascript"
src="http://example1.com/mytest.ashx?proxy">
</script>

If I put the same page on example1.com all work fine. I think that is a
`cross domain` security.

Does Jayrock have a 'cross domain' problem ?

If so, I have a big problem.

Regards,
Alexnaldo Santos

alexnald...@hotmail.com

unread,
Oct 10, 2006, 12:51:07 PM10/10/06
to Jayrock
Yes! It is a cross domain problem....I tried it now...and if I enable
the `cross domain`on Internet Explorer all work fine...My problem is
that my customer can't do it...

Do you know any workaround for it ? I need to call jayrock rpc from
cross domain

Atif Aziz

unread,
Oct 10, 2006, 2:51:07 PM10/10/06
to jay...@googlegroups.com
> Does Jayrock have a 'cross domain' problem ?

This is not a Jayrock problem. Every browser supports this. You can
always source content from multiple web sites. In this sense, it's not
different than getting a GIF file from another web site than the hosting
page. Where you'll be blocked is if the script tries to contact another
domain than the web site the hosting page was downloaded from.

Atif Aziz

unread,
Oct 10, 2006, 2:55:35 PM10/10/06
to jay...@googlegroups.com
The only way to achieve this is through dynamic downloading of <script>
tags. Look at JSONP for some ideas. See also how Flickr does this...
http://www.flickr.com/services/api/response.json.html

-----Original Message-----
From: jay...@googlegroups.com [mailto:jay...@googlegroups.com] On
Behalf Of alexnald...@hotmail.com
Sent: Tuesday, October 10, 2006 6:51 PM
To: Jayrock

alexnald...@hotmail.com

unread,
Oct 10, 2006, 5:23:27 PM10/10/06
to Jayrock
The link doesn't have any example about cross domain.

How I can dynamic download the jayrock scripts ?

Atif Aziz

unread,
Oct 10, 2006, 5:39:52 PM10/10/06
to jay...@googlegroups.com
> How I can dynamic download the jayrock scripts ?

By creating SCRIPT elements through the DOM and then appending them to
the body. For example:

var script = document.createElement("SCRIPT")
script.type = "text/javascript";
script.src = "...";
document.body.appendChild(script);

In IE, you can use the onreadystatechange event on the script to find
out when it's finished downloading.

-----Original Message-----
From: jay...@googlegroups.com [mailto:jay...@googlegroups.com] On
Behalf Of alexnald...@hotmail.com
Sent: Tuesday, October 10, 2006 11:23 PM
To: Jayrock
Subject: [Jayrock] Re: Cross domain problem

alexnald...@hotmail.com

unread,
Oct 10, 2006, 5:50:16 PM10/10/06
to Jayrock
Thanks...

Here a good link too..

http://ajaxpatterns.org/On-Demand_Javascript

alexnald...@hotmail.com

unread,
Oct 11, 2006, 9:35:37 AM10/11/06
to Jayrock
Hi Atif,

I did it but doesn't work. The Cross Domain problem continue....If I
try the same code in same domain all work fine !

function ensureUploadScriptIsLoaded() {
if (self.sunet_ScritLoaded) { // Already exists
return;
}
var head = document.getElementsByTagName("head")[0];
script = document.createElement('script');
script.id = 'monitorScript';
script.type = 'text/javascript';
script.src = 'http://mysite.com/myhandle.ashx?proxy';
head.appendChild(script);
}

Atif Aziz

unread,
Oct 11, 2006, 9:56:30 AM10/11/06
to jay...@googlegroups.com
See the attached file for a working test with Yahoo's Flickr service.
Unzip and save the HTML file on your desktop and run it from there. It
works in IE and FF.

The method I am calling is echo, documented here:
http://www.flickr.com/services/api/flickr.test.echo.html

Hope this helps. As you can see, this isn't a Jayrock topic or issue.

-----Original Message-----
From: jay...@googlegroups.com [mailto:jay...@googlegroups.com] On
Behalf Of alexnald...@hotmail.com
Sent: Wednesday, October 11, 2006 3:36 PM
To: Jayrock
Subject: [Jayrock] Re: Cross domain problem

flickrjsontest.zip

alexnald...@hotmail.com

unread,
Oct 12, 2006, 8:43:46 AM10/12/06
to Jayrock
Great example......!

I changed my code and now work fine !

Thanks,
Alexnaldo Santos

> ------_=_NextPart_001_01C6ED3D.3804D26E
> Content-Type: application/x-zip-compressed
> Content-Transfer-Encoding: base64
> Content-Disposition: inline;
> filename="flickrjsontest.zip"
> Content-Description: flickrjsontest.zip
> X-Google-AttachSize: 812

Reply all
Reply to author
Forward
0 new messages