[jQuery] Re: Cross domain problems

2008-07-24 Thread Erik Beeson

The problem arises when you're on http://username.example.com/ and you
want to make an ajax request to http://example.com/ or you're on
http://example.com and you want to make a ajax request to
http://ajax.example.com/

You'll have cross-domain issues since the domains aren't the same. But
since your SLD is the same, you can set document.domain to
'example.com' and everything will play nice.

If you make your ajax requests to the same server that served up the
page that you're on, then this isn't an issue as you can just us an
absolute URI, as you suggested. But such isn't always the case,
especially on larger sites.

--Erik


On 7/10/08, Vincent Robert <[EMAIL PROTECTED]> wrote:
>
>  I may be misunderstading something here but this does not look like a
>  cross-domain issue to me.
>
>  If you are making AJAX request on the same server that served the
>  page, then you should use absolute URI path without any protocol nor
>  domain name : $.get("/some/web/service"). This will work whatever
>  domain your user typed in his browser (www.example.com or
>  example.com).
>
>  If you are really making a cross-domain AJAX call, meaning that you
>  are calling another server (like yahoo.com or google.com) then
>  browsers will prevent you from doing that and you should rely on a
>  proxy webservice that you must create on your server.
>
>  Have I missed something obvious?
>
>
>
>  On Jul 10, 4:07 am, flycast <[EMAIL PROTECTED]> wrote:
>  > I have determined that the error was from a different script. Sorry
>  > about the confusion.
>  >
>  > After working on the document.domain I could not get it to work/help.
>  > The load statement would just not return any result.
>  >
>  > The solution that Jeffery offered above worked like a champ.
>  >
>  > Thanks for all your help.
>  >
>  > On Jul 9, 11:56 am, "Jeffrey Kretz" <[EMAIL PROTECTED]> wrote:
>  >
>  > > I had this same problem, which I solved by parsing the 
> window.location.href
>  > > prior to making the ajax call, based on the current host used to access 
> the
>  > > site.
>  >
>  > > var url = /(https?:\/\/[^\/]+)/.exec(window.location.href)[1] +
>  > > '/pathtomyresource';
>  >
>  > > JK
>  >
>  > > -Original Message-
>  > > From: jquery-en@googlegroups.com [mailto:[EMAIL PROTECTED] On
>  >
>  > > Behalf Of Erik Beeson
>  > > Sent: Wednesday, July 09, 2008 9:33 AM
>  > > To: jquery-en@googlegroups.com
>  > > Subject: [jQuery] Re: Cross domain problems
>  >
>  > > The protocol *must* be the same (if the page ishttps://.../thenthe
>  > > ajax request must also be tohttps://.../).
>  >
>  > > The port *must* be the same.
>  >
>  > > The host name *must* have the same SLD [1], and if the subdomains are
>  > > different, document.domain *must* be set to the SLD.
>  >
>  > > I'm certain that this can work as I do it all the time. If you're
>  > > still having trouble, could you create a page that demonstrates the
>  > > problem?
>  >
>  > > --Erik
>  >
>  > > [1]http://en.wikipedia.org/wiki/Second-level_domain
>  >
>  > > On 7/9/08,flycast<[EMAIL PROTECTED]> wrote:
>  >
>  > > >  I tried setting document.domain = 'site.com';
>  > > >  It works with a domain of site.com but notwww.site.com. I now get the
>  > > >  following message:
>  >
>  > > >  [Exception... "'Permission denied to call method XMLHttpRequest.open'
>  > > >  when calling method: [nsIDOMEventListener::handleEvent]" nsresult:
>  > > >  "0x8057001e (NS_ERROR_XPC_JS_THREW_STRING)" location: ""
>  > > >  data: no]
>  >
>  > > >  This seems to be a different problem.
>  >
>  > > >  BTW...here is a Mozilla link to the issue of cross domain and the use
>  > > >  of 
> document.domain:http://www.mozilla.org/projects/security/components/same-origin.html
>  >
>  > > >  On Jul 9, 1:30 am, Alexsandro_xpt <[EMAIL PROTECTED]> wrote:
>  > > >  > Well, I thought this is security browser issue.
>  >
>  > > >  > I always solve this problem this way:
>  > > >  > Eg.:
>  >
>  > > >  > To ajax this:http://feedproxy.feedburner.com/undergoogle
>  >
>  > > > > I create
>  > > 
> this:http://blog.alexsandro.com.br/application/load/feedproxy.feedburner.c..
>  > > .
>  

[jQuery] Re: Cross domain problems

2008-07-10 Thread Vincent Robert

I may be misunderstading something here but this does not look like a
cross-domain issue to me.

If you are making AJAX request on the same server that served the
page, then you should use absolute URI path without any protocol nor
domain name : $.get("/some/web/service"). This will work whatever
domain your user typed in his browser (www.example.com or
example.com).

If you are really making a cross-domain AJAX call, meaning that you
are calling another server (like yahoo.com or google.com) then
browsers will prevent you from doing that and you should rely on a
proxy webservice that you must create on your server.

Have I missed something obvious?


On Jul 10, 4:07 am, flycast <[EMAIL PROTECTED]> wrote:
> I have determined that the error was from a different script. Sorry
> about the confusion.
>
> After working on the document.domain I could not get it to work/help.
> The load statement would just not return any result.
>
> The solution that Jeffery offered above worked like a champ.
>
> Thanks for all your help.
>
> On Jul 9, 11:56 am, "Jeffrey Kretz" <[EMAIL PROTECTED]> wrote:
>
> > I had this same problem, which I solved by parsing the window.location.href
> > prior to making the ajax call, based on the current host used to access the
> > site.
>
> > var url = /(https?:\/\/[^\/]+)/.exec(window.location.href)[1] +
> > '/pathtomyresource';
>
> > JK
>
> > -Original Message-
> > From: jquery-en@googlegroups.com [mailto:[EMAIL PROTECTED] On
>
> > Behalf Of Erik Beeson
> > Sent: Wednesday, July 09, 2008 9:33 AM
> > To: jquery-en@googlegroups.com
> > Subject: [jQuery] Re: Cross domain problems
>
> > The protocol *must* be the same (if the page ishttps://.../thenthe
> > ajax request must also be tohttps://.../).
>
> > The port *must* be the same.
>
> > The host name *must* have the same SLD [1], and if the subdomains are
> > different, document.domain *must* be set to the SLD.
>
> > I'm certain that this can work as I do it all the time. If you're
> > still having trouble, could you create a page that demonstrates the
> > problem?
>
> > --Erik
>
> > [1]http://en.wikipedia.org/wiki/Second-level_domain
>
> > On 7/9/08,flycast<[EMAIL PROTECTED]> wrote:
>
> > >  I tried setting document.domain = 'site.com';
> > >  It works with a domain of site.com but notwww.site.com. I now get the
> > >  following message:
>
> > >  [Exception... "'Permission denied to call method XMLHttpRequest.open'
> > >  when calling method: [nsIDOMEventListener::handleEvent]" nsresult:
> > >  "0x8057001e (NS_ERROR_XPC_JS_THREW_STRING)" location: ""
> > >  data: no]
>
> > >  This seems to be a different problem.
>
> > >  BTW...here is a Mozilla link to the issue of cross domain and the use
> > >  of 
> > > document.domain:http://www.mozilla.org/projects/security/components/same-origin.html
>
> > >  On Jul 9, 1:30 am, Alexsandro_xpt <[EMAIL PROTECTED]> wrote:
> > >  > Well, I thought this is security browser issue.
>
> > >  > I always solve this problem this way:
> > >  > Eg.:
>
> > >  > To ajax this:http://feedproxy.feedburner.com/undergoogle
>
> > > > I create
> > this:http://blog.alexsandro.com.br/application/load/feedproxy.feedburner.c..
> > .
>
> > >  > --
> > >  > Alexsandrowww.alexsandro.com.br
>
> > >  > On 9 jul, 00:18, "Erik Beeson" <[EMAIL PROTECTED]> wrote:
>
> > >  > > Add this somewhere in your javascript:
>
> > >  > > document.domain = 'site.com';
>
> > >  > > Google document domain
>
> > >  > > --Erik
>
> > >  > > On 7/8/08,flycast<[EMAIL PROTECTED]> wrote:
>
> > >  > > >  Simple problem (I think)...
>
> > >  > > >  I am new to JS and ajax.
>
> > >  > > >  I am building an ajax capability on a clients site. I am running
> > into
> > >  > > >  cross domain problems. If I get the page using the url
> > formhttp://www.site.com
> > >  > > >  but I do a load using the url form "http://site.com"; (www vs. no
> > www
> > >  > > >  in the url) I get nothing but a js error.
>
> > >  > > >  What is the best way to handle making sure that if the person is
> > at
> > >  > > >  the site with OR without the "www" in the url that the .load will
> > >  > > >  still work?


[jQuery] Re: Cross domain problems

2008-07-09 Thread flycast

I have determined that the error was from a different script. Sorry
about the confusion.

After working on the document.domain I could not get it to work/help.
The load statement would just not return any result.

The solution that Jeffery offered above worked like a champ.

Thanks for all your help.

On Jul 9, 11:56 am, "Jeffrey Kretz" <[EMAIL PROTECTED]> wrote:
> I had this same problem, which I solved by parsing the window.location.href
> prior to making the ajax call, based on the current host used to access the
> site.
>
> var url = /(https?:\/\/[^\/]+)/.exec(window.location.href)[1] +
> '/pathtomyresource';
>
> JK
>
> -Original Message-
> From: jquery-en@googlegroups.com [mailto:[EMAIL PROTECTED] On
>
> Behalf Of Erik Beeson
> Sent: Wednesday, July 09, 2008 9:33 AM
> To: jquery-en@googlegroups.com
> Subject: [jQuery] Re: Cross domain problems
>
> The protocol *must* be the same (if the page ishttps://.../then the
> ajax request must also be tohttps://.../).
>
> The port *must* be the same.
>
> The host name *must* have the same SLD [1], and if the subdomains are
> different, document.domain *must* be set to the SLD.
>
> I'm certain that this can work as I do it all the time. If you're
> still having trouble, could you create a page that demonstrates the
> problem?
>
> --Erik
>
> [1]http://en.wikipedia.org/wiki/Second-level_domain
>
> On 7/9/08,flycast<[EMAIL PROTECTED]> wrote:
>
> >  I tried setting document.domain = 'site.com';
> >  It works with a domain of site.com but notwww.site.com. I now get the
> >  following message:
>
> >  [Exception... "'Permission denied to call method XMLHttpRequest.open'
> >  when calling method: [nsIDOMEventListener::handleEvent]" nsresult:
> >  "0x8057001e (NS_ERROR_XPC_JS_THREW_STRING)" location: ""
> >  data: no]
>
> >  This seems to be a different problem.
>
> >  BTW...here is a Mozilla link to the issue of cross domain and the use
> >  of 
> > document.domain:http://www.mozilla.org/projects/security/components/same-origin.html
>
> >  On Jul 9, 1:30 am, Alexsandro_xpt <[EMAIL PROTECTED]> wrote:
> >  > Well, I thought this is security browser issue.
>
> >  > I always solve this problem this way:
> >  > Eg.:
>
> >  > To ajax this:http://feedproxy.feedburner.com/undergoogle
>
> > > I create
> this:http://blog.alexsandro.com.br/application/load/feedproxy.feedburner.c..
> .
>
> >  > --
> >  > Alexsandrowww.alexsandro.com.br
>
> >  > On 9 jul, 00:18, "Erik Beeson" <[EMAIL PROTECTED]> wrote:
>
> >  > > Add this somewhere in your javascript:
>
> >  > > document.domain = 'site.com';
>
> >  > > Google document domain
>
> >  > > --Erik
>
> >  > > On 7/8/08,flycast<[EMAIL PROTECTED]> wrote:
>
> >  > > >  Simple problem (I think)...
>
> >  > > >  I am new to JS and ajax.
>
> >  > > >  I am building an ajax capability on a clients site. I am running
> into
> >  > > >  cross domain problems. If I get the page using the url
> formhttp://www.site.com
> >  > > >  but I do a load using the url form "http://site.com"; (www vs. no
> www
> >  > > >  in the url) I get nothing but a js error.
>
> >  > > >  What is the best way to handle making sure that if the person is
> at
> >  > > >  the site with OR without the "www" in the url that the .load will
> >  > > >  still work?


[jQuery] Re: Cross domain problems

2008-07-09 Thread Jeffrey Kretz

I had this same problem, which I solved by parsing the window.location.href
prior to making the ajax call, based on the current host used to access the
site.

var url = /(https?:\/\/[^\/]+)/.exec(window.location.href)[1] +
'/pathtomyresource';

JK

-Original Message-
From: jquery-en@googlegroups.com [mailto:[EMAIL PROTECTED] On
Behalf Of Erik Beeson
Sent: Wednesday, July 09, 2008 9:33 AM
To: jquery-en@googlegroups.com
Subject: [jQuery] Re: Cross domain problems


The protocol *must* be the same (if the page is https://.../ then the
ajax request must also be to https://.../).

The port *must* be the same.

The host name *must* have the same SLD [1], and if the subdomains are
different, document.domain *must* be set to the SLD.

I'm certain that this can work as I do it all the time. If you're
still having trouble, could you create a page that demonstrates the
problem?

--Erik

[1] http://en.wikipedia.org/wiki/Second-level_domain


On 7/9/08, flycast <[EMAIL PROTECTED]> wrote:
>
>  I tried setting document.domain = 'site.com';
>  It works with a domain of site.com but not www.site.com. I now get the
>  following message:
>
>  [Exception... "'Permission denied to call method XMLHttpRequest.open'
>  when calling method: [nsIDOMEventListener::handleEvent]" nsresult:
>  "0x8057001e (NS_ERROR_XPC_JS_THREW_STRING)" location: ""
>  data: no]
>
>  This seems to be a different problem.
>
>  BTW...here is a Mozilla link to the issue of cross domain and the use
>  of document.domain:
http://www.mozilla.org/projects/security/components/same-origin.html
>
>
>
>
>  On Jul 9, 1:30 am, Alexsandro_xpt <[EMAIL PROTECTED]> wrote:
>  > Well, I thought this is security browser issue.
>  >
>  > I always solve this problem this way:
>  > Eg.:
>  >
>  > To ajax this:http://feedproxy.feedburner.com/undergoogle
>  >
>
> > I create
this:http://blog.alexsandro.com.br/application/load/feedproxy.feedburner.c..
.
>  >
>  > --
>  > Alexsandrowww.alexsandro.com.br
>
> >
>  > On 9 jul, 00:18, "Erik Beeson" <[EMAIL PROTECTED]> wrote:
>  >
>  > > Add this somewhere in your javascript:
>  >
>  > > document.domain = 'site.com';
>  >
>  > > Google document domain
>  >
>  > > --Erik
>  >
>  > > On 7/8/08, flycast <[EMAIL PROTECTED]> wrote:
>  >
>  > > >  Simple problem (I think)...
>  >
>  > > >  I am new to JS and ajax.
>  >
>  > > >  I am building an ajax capability on a clients site. I am running
into
>  > > >  cross domain problems. If I get the page using the url
formhttp://www.site.com
>  > > >  but I do a load using the url form "http://site.com"; (www vs. no
www
>  > > >  in the url) I get nothing but a js error.
>  >
>  > > >  What is the best way to handle making sure that if the person is
at
>  > > >  the site with OR without the "www" in the url that the .load will
>  > > >  still work?
>



[jQuery] Re: Cross domain problems

2008-07-09 Thread Erik Beeson

The protocol *must* be the same (if the page is https://.../ then the
ajax request must also be to https://.../).

The port *must* be the same.

The host name *must* have the same SLD [1], and if the subdomains are
different, document.domain *must* be set to the SLD.

I'm certain that this can work as I do it all the time. If you're
still having trouble, could you create a page that demonstrates the
problem?

--Erik

[1] http://en.wikipedia.org/wiki/Second-level_domain


On 7/9/08, flycast <[EMAIL PROTECTED]> wrote:
>
>  I tried setting document.domain = 'site.com';
>  It works with a domain of site.com but not www.site.com. I now get the
>  following message:
>
>  [Exception... "'Permission denied to call method XMLHttpRequest.open'
>  when calling method: [nsIDOMEventListener::handleEvent]" nsresult:
>  "0x8057001e (NS_ERROR_XPC_JS_THREW_STRING)" location: ""
>  data: no]
>
>  This seems to be a different problem.
>
>  BTW...here is a Mozilla link to the issue of cross domain and the use
>  of document.domain: 
> http://www.mozilla.org/projects/security/components/same-origin.html
>
>
>
>
>  On Jul 9, 1:30 am, Alexsandro_xpt <[EMAIL PROTECTED]> wrote:
>  > Well, I thought this is security browser issue.
>  >
>  > I always solve this problem this way:
>  > Eg.:
>  >
>  > To ajax this:http://feedproxy.feedburner.com/undergoogle
>  >
>
> > I create 
> > this:http://blog.alexsandro.com.br/application/load/feedproxy.feedburner.c...
>  >
>  > --
>  > Alexsandrowww.alexsandro.com.br
>
> >
>  > On 9 jul, 00:18, "Erik Beeson" <[EMAIL PROTECTED]> wrote:
>  >
>  > > Add this somewhere in your javascript:
>  >
>  > > document.domain = 'site.com';
>  >
>  > > Google document domain
>  >
>  > > --Erik
>  >
>  > > On 7/8/08, flycast <[EMAIL PROTECTED]> wrote:
>  >
>  > > >  Simple problem (I think)...
>  >
>  > > >  I am new to JS and ajax.
>  >
>  > > >  I am building an ajax capability on a clients site. I am running into
>  > > >  cross domain problems. If I get the page using the url 
> formhttp://www.site.com
>  > > >  but I do a load using the url form "http://site.com"; (www vs. no www
>  > > >  in the url) I get nothing but a js error.
>  >
>  > > >  What is the best way to handle making sure that if the person is at
>  > > >  the site with OR without the "www" in the url that the .load will
>  > > >  still work?
>


[jQuery] Re: Cross domain problems

2008-07-09 Thread Ryura

What JS error were you getting before?

On Jul 9, 8:01 am, flycast <[EMAIL PROTECTED]> wrote:
> I tried setting document.domain = 'site.com';
> It works with a domain of site.com but notwww.site.com. I now get the
> following message:
>
> [Exception... "'Permission denied to call method XMLHttpRequest.open'
> when calling method: [nsIDOMEventListener::handleEvent]" nsresult:
> "0x8057001e (NS_ERROR_XPC_JS_THREW_STRING)" location: ""
> data: no]
>
> This seems to be a different problem.
>
> BTW...here is a Mozilla link to the issue of cross domain and the use
> of 
> document.domain:http://www.mozilla.org/projects/security/components/same-origin.html
>
> On Jul 9, 1:30 am, Alexsandro_xpt <[EMAIL PROTECTED]> wrote:
>
> > Well, I thought this is security browser issue.
>
> > I always solve this problem this way:
> > Eg.:
>
> > To ajax this:http://feedproxy.feedburner.com/undergoogle
>
> > I create 
> > this:http://blog.alexsandro.com.br/application/load/feedproxy.feedburner.c...
>
> > --
> > Alexsandrowww.alexsandro.com.br
>
> > On 9 jul, 00:18, "Erik Beeson" <[EMAIL PROTECTED]> wrote:
>
> > > Add this somewhere in your javascript:
>
> > > document.domain = 'site.com';
>
> > > Google document domain
>
> > > --Erik
>
> > > On 7/8/08, flycast <[EMAIL PROTECTED]> wrote:
>
> > > >  Simple problem (I think)...
>
> > > >  I am new to JS and ajax.
>
> > > >  I am building an ajax capability on a clients site. I am running into
> > > >  cross domain problems. If I get the page using the url 
> > > > formhttp://www.site.com
> > > >  but I do a load using the url form "http://site.com"; (www vs. no www
> > > >  in the url) I get nothing but a js error.
>
> > > >  What is the best way to handle making sure that if the person is at
> > > >  the site with OR without the "www" in the url that the .load will
> > > >  still work?


[jQuery] Re: Cross domain problems

2008-07-09 Thread flycast

I tried setting document.domain = 'site.com';
It works with a domain of site.com but not www.site.com. I now get the
following message:

[Exception... "'Permission denied to call method XMLHttpRequest.open'
when calling method: [nsIDOMEventListener::handleEvent]" nsresult:
"0x8057001e (NS_ERROR_XPC_JS_THREW_STRING)" location: ""
data: no]

This seems to be a different problem.

BTW...here is a Mozilla link to the issue of cross domain and the use
of document.domain: 
http://www.mozilla.org/projects/security/components/same-origin.html



On Jul 9, 1:30 am, Alexsandro_xpt <[EMAIL PROTECTED]> wrote:
> Well, I thought this is security browser issue.
>
> I always solve this problem this way:
> Eg.:
>
> To ajax this:http://feedproxy.feedburner.com/undergoogle
>
> I create 
> this:http://blog.alexsandro.com.br/application/load/feedproxy.feedburner.c...
>
> --
> Alexsandrowww.alexsandro.com.br
>
> On 9 jul, 00:18, "Erik Beeson" <[EMAIL PROTECTED]> wrote:
>
> > Add this somewhere in your javascript:
>
> > document.domain = 'site.com';
>
> > Google document domain
>
> > --Erik
>
> > On 7/8/08, flycast <[EMAIL PROTECTED]> wrote:
>
> > >  Simple problem (I think)...
>
> > >  I am new to JS and ajax.
>
> > >  I am building an ajax capability on a clients site. I am running into
> > >  cross domain problems. If I get the page using the url 
> > > formhttp://www.site.com
> > >  but I do a load using the url form "http://site.com"; (www vs. no www
> > >  in the url) I get nothing but a js error.
>
> > >  What is the best way to handle making sure that if the person is at
> > >  the site with OR without the "www" in the url that the .load will
> > >  still work?


[jQuery] Re: Cross domain problems

2008-07-08 Thread Alexsandro_xpt

Well, I thought this is security browser issue.

I always solve this problem this way:
Eg.:

To ajax this:
http://feedproxy.feedburner.com/undergoogle

I create this:
http://blog.alexsandro.com.br/application/load/feedproxy.feedburner.com/undergoogle







--
Alexsandro
www.alexsandro.com.br


On 9 jul, 00:18, "Erik Beeson" <[EMAIL PROTECTED]> wrote:
> Add this somewhere in your javascript:
>
> document.domain = 'site.com';
>
> Google document domain
>
> --Erik
>
> On 7/8/08, flycast <[EMAIL PROTECTED]> wrote:
>
>
>
> >  Simple problem (I think)...
>
> >  I am new to JS and ajax.
>
> >  I am building an ajax capability on a clients site. I am running into
> >  cross domain problems. If I get the page using the url 
> > formhttp://www.site.com
> >  but I do a load using the url form "http://site.com"; (www vs. no www
> >  in the url) I get nothing but a js error.
>
> >  What is the best way to handle making sure that if the person is at
> >  the site with OR without the "www" in the url that the .load will
> >  still work?


[jQuery] Re: Cross domain problems

2008-07-08 Thread Erik Beeson

Add this somewhere in your javascript:

document.domain = 'site.com';

Google document domain

--Erik


On 7/8/08, flycast <[EMAIL PROTECTED]> wrote:
>
>  Simple problem (I think)...
>
>  I am new to JS and ajax.
>
>  I am building an ajax capability on a clients site. I am running into
>  cross domain problems. If I get the page using the url form 
> http://www.site.com
>  but I do a load using the url form "http://site.com"; (www vs. no www
>  in the url) I get nothing but a js error.
>
>  What is the best way to handle making sure that if the person is at
>  the site with OR without the "www" in the url that the .load will
>  still work?
>