Go Back   CodingForums.com > :: Client side development > JavaScript programming > Ajax and Design

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 04-09-2009, 09:26 AM   PM User | #1
can_i_say
New to the CF scene

 
Join Date: Apr 2009
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
can_i_say is an unknown quantity at this point
AJAX in IE

I'm having some trouble with AJAX/PHP and IE. My scripts work in all other major browsers (Firefox, Safari, Opera, Chrome) but don't work in IE, and I'm not sure why as I'm fairly new to JavaScript.

Code:
var xmlHttp;

function contactRequest(user_id, requested_by_id, action, i){
	xmlHttp=GetXmlHttpObject();

	var url="ajax/requestContact.php";
	url=url+"?user_id="+user_id;
	url=url+"&requested_by_id="+requested_by_id;
	url=url+"&action="+action;


	xmlHttp.onreadystatechange= function() {
        if (xmlHttp.readyState==4)
            if (xmlHttp.status==200)
                stateChanged2(i); }

	xmlHttp.open("GET",url,true);
	xmlHttp.send(null);
}


function stateChanged2(tag){

 		document.getElementById('contactForm').style.display = 'none';
		document.getElementById("contact"+tag).innerHTML=xmlHttp.responseText;
}

function GetXmlHttpObject(){
	var xmlHttp=null;

	try {
	 // Firefox, Opera 8.0+, Safari
	 xmlHttp=new XMLHttpRequest();
 	}

	catch (e) {
	 	//Internet Explorer
	 		xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");

 	}

return xmlHttp;
}
When the button calling the function is clicked the div is hidden but the PHP script ajax/requestContact.php appears not be to be invoked in IE. Any pointers?
can_i_say is offline   Reply With Quote
Old 04-12-2009, 02:33 PM   PM User | #2
A1ien51
Senior Coder

 
A1ien51's Avatar
 
Join Date: Jun 2002
Location: Between DC and Baltimore In a Cave
Posts: 2,717
Thanks: 1
Thanked 94 Times in 88 Posts
A1ien51 will become famous soon enough
Have you added alert statments to see if the code is being called and see if it makes through the functions. Is the call coming back as something other than 200?

Eric
__________________
Tech Author [Ajax In Action, JavaScript: Visual Blueprint]
A1ien51 is offline   Reply With Quote
Old 04-12-2009, 03:33 PM   PM User | #3
bdl
Regular Coder

 
Join Date: Apr 2007
Location: Camarillo, CA US
Posts: 590
Thanks: 4
Thanked 83 Times in 82 Posts
bdl is an unknown quantity at this point
Code:
xmlHttp.onreadystatechange= function() {
        if (xmlHttp.readyState==4)
            if (xmlHttp.status==200)
                stateChanged2(i); }
This is really confusing. You should clean this up by explicitly defining blocks and using some proper indentation.

Where is i defined? I know that IE can have a problem with vars that are not explicitly defined, this may be the issue.
bdl is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 05:04 PM.


Advertisement
Log in to turn off these ads.