Cross Domain Ajax using Prototype.js and Ajax Extended
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
getTransport: function() {
return Try.these(
function() {return new ActiveXObject('Msxml2.XMLHTTP')},
function() {return new ActiveXObject('Microsoft.XMLHTTP')},
function() {return new XMLHttpRequest()}
) || false;
},Needs to be changed to:
getTransport: function() {
return xmlhttp = new XMLHTTP();
},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.
About this entry
You’re currently reading “Cross Domain Ajax using Prototype.js and Ajax Extended,” an entry on Ajax Lessons

- 2.14.06 / 12am

5 Comments
Jump to comment form | comments rss [?] | trackback uri [?]