Cross Domain Ajax using Prototype.js and Ajax Extended

Filed Under (Lessons, Tutorials) by admin on 14-02-2006

This is a quick guide to building cross domain Ajax applications using Prototype.js and Ajax Extended. First thing you will need to do is download the two needed libraries.

Prototype.js
http://prototype.conio.net/
Ajax Extended
http://ajaxextended.com/

First thing we need to do is modify prototype.js to use the Ajax Extended XMLHTTP object rather than Javascript’s native one.

Prototype.js

[code]getTransport: function() {
return Try.these(
function() {return new ActiveXObject(’Msxml2.XMLHTTP’)},
function() {return new ActiveXObject(’Microsoft.XMLHTTP’)},
function() {return new XMLHttpRequest()}
) || false;
},[/code]

Needs to be changed to:

[code]getTransport: function() {
return xmlhttp = new XMLHTTP();
},[/code]

You can now use cross domain Ajax using prototype.js while keeping all the functionality of prototype.js. Make sure you upload the Ajax Extended files and that you configue the Javascript file to point to your PHP file.

Watch AjaxLessons.com for a full tutorial on cross domain Ajax this week.

Download Modded Prototype.js and Ajax Extended

Share and Enjoy:
  • Digg
  • del.icio.us
  • Technorati
  • Google
  • Reddit
  • Slashdot
  • StumbleUpon
  • YahooMyWeb

Comments:

6 Comments posted for Cross Domain Ajax using Prototype.js and Ajax Extended

Make a comment