The problem is that you're wiping out the form before you get the value from it:
Code:
function ajaxSaveMsg(divTag)
{
if (window.XMLHttpRequest)
{// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp=new XMLHttpRequest();
}
else
{// code for IE6, IE5
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
//loading animation
document.getElementById([divTag]).innerHTML="loading...";
xmlhttp.onreadystatechange=function()
{
if (xmlhttp.readyState==4 && xmlhttp.status==200)
{
document.getElementById([divTag]).innerHTML=xmlhttp.responseText;
parent.calcHeight();
}
}
xmlhttp.open("POST","new_msg_save.php",true);
xmlhttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded; charset=UTF-8');
xmlhttp.send("sbj=" + encodeURIComponent(document.getElementById("sbj").value));
}.
You can probably do like so:
Code:
function ajaxSaveMsg(divTag)
{
if (window.XMLHttpRequest)
{// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp=new XMLHttpRequest();
}
else
{// code for IE6, IE5
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
var data = document.getElementById("sbj").value;
//loading animation
document.getElementById([divTag]).innerHTML="loading...";
xmlhttp.onreadystatechange=function()
{
if (xmlhttp.readyState==4 && xmlhttp.status==200)
{
document.getElementById([divTag]).innerHTML=xmlhttp.responseText;
parent.calcHeight();
}
}
xmlhttp.open("POST","new_msg_save.php",true);
xmlhttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded; charset=UTF-8');
xmlhttp.send("sbj=" + data);
}
Incidentally, parent.calcHeight();
is not a function and is causing an error. So either remove it from this and the GET function (the one named ajaxRequest) or create/define it. Since it comes after everything else is done, it doesn't appear to cause any real problems. But it might at some point.
Bookmarks