Some ajax help
Posted: Tue Feb 16, 2010 10:34 am
Is there a way to load a php script with ajax on page load. I've gotten this script I have for onclick to do it onload but it works in everything but in IE (stupid piece of junk)... What happens is it loads when you go to the page, but if you login it stops working. Not much changes, no div changes, so I'm not quite sure what is happening.
If you want to test it:
http://jefffan24.com/copy/
Log In:
Username: testuser
Password: freckles
So I guess my question is how do i get this to work in IE.
If you want to test it:
http://jefffan24.com/copy/
Log In:
Username: testuser
Password: freckles
Code: Select all
function ajaxFunction(){
var ajaxRequest; //The var
try {
//Opera 8.0+, Firefox, Safari
ajaxRequest = new XMLHttpRequest();
} catch (e) {
//IE browsers
try {
ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP");
} catch (e){
try {
ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP");
} catch (e) {
//Something went wrong
alert("Your Browser be broke!");
return false;
}
}
}
// Creates a function that will receive data sent from the server
ajaxRequest.onreadystatechange = function(){
if(ajaxRequest.readyState == 4){
var ajaxDisplay = document.getElementById('news');
ajaxDisplay.innerHTML = ajaxRequest.responseText;
}
}
ajaxRequest.open("GET", "show_news.php", true);
ajaxRequest.send(null);
}