Page 1 of 1

Ajax cross server request

Posted: Thu Mar 12, 2009 12:34 pm
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)

Ajax cross server request

Posted: Thu Mar 12, 2009 1:38 pm
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.

Ajax cross server request

Posted: Fri Mar 13, 2009 12:06 pm
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

Ajax cross server request

Posted: Fri Mar 13, 2009 12:57 pm
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>