To repeat previous answers, you cannot make XHR calls cross domain from the
browser (you seem not to be understanding that point).

Having said that, there are two ways to solve your problem though...

One, distribute your widget as an iframe that points to a page on your
domain instead of as script people put on their pages.
Two, create your back end (the one that the AJAX calls are being made to
now) to be capable of returning pure javascript, and instead of doing XHR
calls to that endpoint, use dynamic script tag injection. For details on how
to do that, use Google.




On Wed, Sep 17, 2008 at 8:30 AM, Rama <[EMAIL PROTECTED]> wrote:

>
> ok.
> The above solution works when javascript is on my domain.
> ((in javascript) instead of cross domain i will interact with my
> server , the server will fetch that page)
>
> But what to do when iam placing the javascript from mydomain.com in
> another domain say xyz.com where the javascript loaded from
> mydomain.com on a page at xyz.com wants to interact with the
> mydomain.com server.
>
> in those case How should we do cross domain Ajax (or XHR calls)?
>
> (the above scenario is occurring for me while building a small widget
> (javascript based) which any websites can put on their page )).where
> iam actually planning to bring data for the widget by calling  AJAX./
> XHR call to my server.
>
>
> regards
> rama
>
>
> On Sep 17, 5:46 pm, bluezehn <[EMAIL PROTECTED]> wrote:
> > A suggestion: make them to your domain, then have a server side script
> > on the same domain which uses something akin to php's curllib to make
> > a request to another server and return that server's response. I don't
> > know any other way in which this is possible.
> >
> > On Sep 17, 1:07 pm, Rama <[EMAIL PROTECTED]> wrote:
> >
> > > ok understood.
> >
> > > then how can we  make AJAX (XHR) calls to other domain ?
> >
> > > Is it actually possible?
> >
> > > Regards
> > > rama
> >
> > > On Sep 17, 4:49 am, "Diogo Neves" <[EMAIL PROTECTED]> wrote:
> >
> > > > Hi,
> >
> > > > On Wed, Sep 17, 2008 at 12:38 AM, Rama <[EMAIL PROTECTED]>
> wrote:
> >
> > > > > iam  not violating the same origin policy that which the  browers
> > > > > follow.
> >
> > > > > Scenario1 )    Script is  loading from  mydomain.com,script is
> > > > > residing  on the same mydomain.com
> >
> > > > >                     in this case everything is  working fine.
> >
> > > > > Scnario2) Script is loading from  mydomain.com, script  is
> residing on
> > > > > other domain say xyza.com
> >
> > > > >                Even though script is residing on xyza.com
> > > > >               the script downloaded form mydomain.com is making
> calls
> > > > > Ajax calls (XHR request/response) to only mydomain.com
> >
> > > > >                in the above case it is still not violating th same
> > > > > ORgin policy.
> >
> > > > Wrong... the domain of the webpage is what counts, not the script
> domain...
> > > > But u can always use the appendChild tecnique...
> >
> > > > >                in the second scenario also it should work
> > > > > correctly.but it is not working ...............
> >
> > > > >               i could not able to figure it out the mistake that
>  iam
> > > > > doing.
> >
> > > > > On Sep 17, 12:23 am, Diodeus <[EMAIL PROTECTED]> wrote:
> > > > > > Assuming you are attempting to make an Ajax call to a server that
> is
> > > > > > not in your web page's domain, it is a deliberate security
> restriction
> > > > > > in the browser designed to prevent cross-site scripting (XSS)
> attacks.
> >
> > > > > > On Sep 16, 1:34 pm, Rama <[EMAIL PROTECTED]> wrote:
> >
> > > > > > > hi,
> >
> > > > > > > i have developed a widget/badge in javasript. (using
> prototypejs)
> >
> > > > > > > It is working  well on my  own site.  but when placed on other
> > > > > > > domains  AJAX(XHR) requests are not working porperly.
> >
> > > > > > > Can anyone  please guide us  on why the ajax(XHR)
>  calls/requests  are
> > > > > > > not working when placed on other doman.
> >
> > > > > > > Regards
> > > > > > > rama
> >
> > > > --
> > > > Thanks,
> >
> > > > Diogo Neves
> > > > Web Developer @ SAPO.pt by PrimeIT.pt
> >
>


-- 
Ryan Gahl
Manager, Senior Software Engineer
Nth Penguin, LLC
http://www.nthpenguin.com
--
WebWidgetry.com / MashupStudio.com
Future Home of the World's First Complete Web Platform
--
Inquire: 1-920-574-2218
Blog: http://www.someElement.com
LinkedIn Profile: http://www.linkedin.com/in/ryangahl

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Prototype & script.aculo.us" group.
To post to this group, send email to prototype-scriptaculous@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/prototype-scriptaculous?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to