I have sommen problems to get my AJAX Code to work whit “Post” i can get it to work to “GET” and here is my AJAX Code i hob i can be helpet her.
[code]
/* Will make the xmlHttp request to load the file ind the Firefox, Opera, Internet Explore and more browseres */
function makeRequestObj()
{
// Try Opera, Firefox, etc. browser method first
try
{
XMLHttpRec = new XMLHttpRequest();
}
catch (e)
{
// That method failed so try the Microsoft method
try
{
XMLHttpRec = new ActiveXObject(“Msxml2.XMLHTTP”);
}
catch (e)
{
// OK – that failed, so try the older Microsoft ActiveX Object
try
{
XMLHttpRec = new ActiveXObject(“Microsoft.XMLHTTP”);
}
catch (e)
{
// Total failure – set XMLHttpRec to a boolean “false” value
XMLHttpRec = false;
}
}
}
// Pop up an alert box if there has been problems creating the object
if (!XMLHttpRec)
{
alert(“Error initializing XMLHttpRequest!”);
}
return (XMLHttpRec);
}
/*
GET GET GET GET GET GET GET GET GET GET
This code use to be call this file you whot to call
RequestObj = The Obj we definde to call a new xmlHttp request
url = The URL we load e.g test.htm
responseToId = Whit id tag on the pages we will change
*/
function xmlHttp(RequestObj, url, responseToId)
{
RequestObj.open(“GET”, url, true);
RequestObj.onreadystatechange = function ResponsToIdPage()
{
if (RequestObj.readyState == 4)
{
if (RequestObj.status == 200)
{
document.getElementById(responseToId).innerHTML = RequestObj.responseText;
}
}
}
RequestObj.send(null);
}
/*
POST POST POST POST POST POST POST POST
This code use to be call this file you whot to call
RequestObj = The Obj we definde to call a new xmlHttp request
url = The URL we load e.g test.htm
responseToId = Whit id tag on the pages we will change
*/
function DoPostRequest(RequestObj, url, responseToId)
{
RequestObj.open(“POST”, url,false);
RequestObj.setRequestHeader(‘Content-Type’, ‘application/x-www-form-urlencoded’);
RequestObj.send(param);
if (RequestObj.status == 200)
{
return RequestObj.responseText;
}
else
{
return RequestObj.status;
}
}
Ajax_TestVar = makeRequestObj();