...

View Full Version : AJAX Form post method dead



neomaximus2k
02-06-2007, 12:30 PM
ok guys this is really narking me off, using the following script as an AJAX form submitter, now I have used this code on other sites and it has always worked however I have two scripts that just refuse to work with it.


function getHTTPObject() {
var xmlhttp;
/*@cc_on
@if (@_jscript_version >= 5)
try {
xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
} catch (e) {
try {
xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
} catch (E) {
xmlhttp = false;
}
}
@else
xmlhttp = false;
@end @*/
if (!xmlhttp && typeof XMLHttpRequest != 'undefined') {
try {
xmlhttp = new XMLHttpRequest();
} catch (e) {
xmlhttp = false;
}
}
return xmlhttp;
}
var http = getHTTPObject(); // We create the HTTP Object
// End XML Object Loader
var url = "urlhereisvoid"; // The server-side script




function submitform(){
// first check the form is complete
ERROR = "";
if (document.getElementById("name").value.length < 1)ERROR = ERROR + "Your name is missing.\n";
if (document.getElementById("email").value.length < 1)ERROR = ERROR + "Your email is missing.\n";
if (document.getElementById("comments").value.length < 1)ERROR = ERROR + "Your comments aremissing.\n";

if (ERROR == ""){

// dissable the button
document.getElementById("Submit").disabled = true;
document.getElementById("messagediv").innerHTML = "<img src=\"<? echo $websiteurl;?>images/basket_loader_green.gif\" alt=\"Please Wait Loading Data\" width=\"67\" height=\"24\" />";

// grab the data from the server and do what needs to be done
var URL = "<? echo $websiteurl;?>AJAX/testimonials_ajax.php";
PARAMETERS = "name=" + encodeURI(document.getElementById("name").value);
PARAMETERS = PARAMETERS + "&email=" + encodeURI(document.getElementById("email").value);
PARAMETERS = PARAMETERS + "&comments=" + encodeURI(document.getElementById("comments").value);
PARAMETERS = PARAMETERS + "&url=" + encodeURI(document.getElementById("url").value);
PARAMETERS = PARAMETERS + "&Submit=Submit";

// post the info to the URL
http.onreadystatechange = testimonialsent;
http.open('POST', URL, true);
http.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
// http.setRequestHeader("Content-length", PARAMETERS.length);
http.setRequestHeader("Connection", "close");
http.send(PARAMETERS);*/

} else {
alert("There was an error with your submittion.\n"+ERROR+"Please check and try again.");
}
}


Now it finds the file on the server perfect, but it is not Posting the information :S

I setup a print_r($_POST) on there and the array is totally blank, so i used alert(PARAMETERS) to check that was correct and it is, as far as I can tell something is stopping it from posting the data and I cant find out what it is.

Everything is communicating it just aint posting the data tis very frustrating.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum