Go Back   CodingForums.com > :: Client side development > JavaScript programming

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 02-06-2007, 11:30 AM   PM User | #1
neomaximus2k
Regular Coder

 
Join Date: Jan 2007
Posts: 213
Thanks: 0
Thanked 0 Times in 0 Posts
neomaximus2k is an unknown quantity at this point
Angry AJAX Form post method dead

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.

Code:
	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.
__________________
Matthew Bagley
Paramiliar Design Studios
Website Design | Website Development | Search Engine Optimisation (SEO)
neomaximus2k is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 10:52 PM.


Advertisement
Log in to turn off these ads.