nxt's place

Tag: domain

cross domain AJAX

by on Nov.24, 2006, under Java

Using AJAX (which implies the use of the XMLHttpRequest) has one big
limitation, you can only make requests to the server from where the
page was downloaded.
As an alternative you can use javascript to dynamically include other javascript files which should be generated serverside.

An example on how to call the server:

function callServer() {
 var head = document.getElementsByTagName("head").item(0);
 var myTag = document.createElement("script");
 myTag.setAttribute("type", "text/javascript");
 myTag.setAttribute("src",
  "http://example.com/application/getjs/?var1=value1");
 head.appendChild(myTag);
}

The idea is that you generate the javascript that you need by dynamically add another script tag on the page.
for an excellent example of this approach you can read this javaworld article

Comments Off on cross domain AJAX :, , more...

Looking for something?

Use the form below to search the site:

Still not finding what you're looking for? Drop a comment on a post or contact us so we can take care of it!

Blogroll

A few highly recommended websites...