Welcome to MSFN

Register now to gain access to all of our features. Once registered and logged in, you will be able to contribute to this site by submitting your own content or replying to existing content. You'll be able to customize your profile, receive reputation points as a reward for submitting content, while also communicating with other members via your own private inbox, plus much more! This message will be removed once you have signed in.


Urgent: Ajax, passing multiple parameters

1 post in this topic


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
//Firefox, Opera 8.0+, Safari
xmlHttp = new XMLHttpRequest();
//Internet Explorer
xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
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);
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



Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.