Ajax cross server request

Post Reply
gaurav.shetti
Posts: 119
Joined: Fri Feb 27, 2009 9:09 am

Ajax cross server request

Post by gaurav.shetti »

I want to popup an ajax on my server. Ths scenario is this
there is a html page xyz.com on a different server
the page abc is a vortex page which is on another server. Now i want to make a call from abc to xyz ... in other words i want to fetch the contents of abc (ajax popup) on certain events which occur (clicking on icon) on abc page. Since cross server request is not allowed in case of ajax, how do i do it (in vortex)
User avatar
John
Site Admin
Posts: 2622
Joined: Mon Apr 24, 2000 3:18 pm
Location: Cleveland, OH
Contact:

Ajax cross server request

Post by John »

What you need to do is have the Vortex script proxy. The basic idea is as follows, a Vortex function:

<a name=proxyajax public>
<fetch http://ajaxserver/page>
<fmt %s $ret>
</a>

How complex the function needs to be will depend on the arguments and datatypes being sent. It could be a more complex function that can proxy any URL and post data, or if it is geared to that one popup it may be much simpler.
John Turnbull
Thunderstone Software
gaurav.shetti
Posts: 119
Joined: Fri Feb 27, 2009 9:09 am

Ajax cross server request

Post by gaurav.shetti »

Well John this is a good suggestion. What if the page ajaxserver/page requires authentication. The page where i am calling the Vortex function proxyajax is authenticated and the cookies are set. But while making the request to ajaxserver how do i forward the cookies so that i am not redirected to SSO Authentication
User avatar
John
Site Admin
Posts: 2622
Joined: Mon Apr 24, 2000 3:18 pm
Location: Cleveland, OH
Contact:

Ajax cross server request

Post by John »

Assuming that both servers are in the same domain and the authentication cookie is a domain cookie, you can set the cookie before the fetch. If you know the name of the cookie you can do:

<header COOKIE=CookieName VALUE=$CookieName>

If the cookies might be variable:

<varinfo list COOKIE>
<$cookies=$ret>
<loop $cookies>
<getvar $cookies>
<header COOKIE=$cookies VALUE=$ret>
</loop>
John Turnbull
Thunderstone Software
Post Reply