Reputation: 1611
The code below is an ajax create function which is written in JS.
this works on Firefox
, Safari
and Chrome
perfectly but doesn't work on IE6
& IE7
.
How can fix my code to load ajax?
function ajaxCreateRequest() {
var request = false;
if(window.XMLHttpRequest) {
request = new XMLHttpRequest;
}
else if(window.ActiveXObject) {
request = new ActiveXObject("Microsoft.XMLHTTP");
}
if(!request)
alert("This Browser doesn't support my page!");
return request;
}
Upvotes: 0
Views: 2296
Reputation: 5108
Whilst I do not foresee/observe any conspicuous issue in your above posted code, why not use existing javascript framework (they make up excellent javascript abstractions) like
1) JQuery
2) Mootools
3) Prototype.js
If you try to write this on your own by using the archaic code that you have posted above, you'll have to burn your fingers while making it cross-browser compatible.
Read up more on jQuery AJAX here
Upvotes: 1