MSFN Forum: Urgent: Ajax, passing multiple parameters - MSFN Forum

Jump to content


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Urgent: Ajax, passing multiple parameters Rate Topic: -----

#1 User is offline   HighDarkTemplar 

  • Member
  • PipPip
  • Group: Members
  • Posts: 109
  • Joined: 20-January 05

Posted 13 March 2012 - 08:40 AM

Hi!
I'm having some trouble making an ajax-script more flexible so I can use the same script over and over again without having to hard-code it every time.

function getXMLHttp(){
	var xmlHttp
	try{
		//Firefox, Opera 8.0+, Safari
		xmlHttp = new XMLHttpRequest();
	}
  catch(e){
	//Internet Explorer
		try{
			xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
		}
	catch(e){
		try{
			xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
		}
		catch(e){
			alert("Your browser does not support AJAX!")
			return false;
		}
	}
	}
	return xmlHttp;
}

function MakeRequest(phpfile, targetdiv){
  var xmlHttp = getXMLHttp();  
	xmlHttp.onreadystatechange = function(){
		if(xmlHttp.readyState == 4){
			HandleResponse(xmlHttp.responseText, targetdiv);
			}
	}
	xmlHttp.open("GET", phpfile , true); 
	xmlHttp.send(null);
}
function HandleResponse(response, divtag){
	document.getElementById(divtag).innerHTML = response;
}


The problem is getting the "targetdiv"/"divtag" to work. The script works well if I just use "document.getElementById('mydivtag').innerHTML=response;"

I've been googling for a while, and had a quick search here on the forum but I didn't find anything of value...

Thanks for your attention!



Best Regards
-HighDarkTemplar


Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

2 User(s) are reading this topic
0 members, 2 guests, 0 anonymous users



All trademarks mentioned on this page are the property of their respective owners
Copyright © 2001 - 2013 msfn.org
Privacy Policy