Jump to content


Posting to PHP with AJAX


2 replies to this topic

#1 Hayden

    P2L Jedi

  • Members
  • PipPipPip
  • 716 posts
  • Gender:Male
  • Location:Texas

Posted 04 May 2006 - 12:24 PM

Okay, i've gotten to work with the $_GET method and I think it's working with $_POST, but I don't know where in the $_POST array it's putting the data and/or how to specify in my javascript/ajax function.

<script language="JavaScript">
	function sendData(str){
		var xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
		xmlhttp.Open("POST", "http://www.boothelp.us/bbcode_backend.php?bbcode="+str, false);
		xmlhttp.Send();
		divDisplay.innerHTML=xmlhttp.responseText;
	}
</script>
<body>
<form method="post"><textarea name="bbcode" onkeyup='sendData(this.value)'></textarea></form>
<div id='divDisplay' style="width: 300px; height: 300px; border: 1px solid #000000; background-color: #737373;"></div>
</body>

btw, i've tried it in the xmlhttp.Send() as well. the paste is from the last edition i have made.

#2 rc69

    PHP Master PD

  • P2L Staff
  • PipPipPipPip
  • 3,827 posts
  • Gender:Male
  • Location:Here
  • Interests:Web Development

Posted 04 May 2006 - 03:06 PM

you've got to add the query string to the send() function just as you would in the url.
xmlhttp.Open("POST", "http://www.boothelp.us/bbcode_backend.php", false);
xmlhttp.Send("bbcode="+str);


#3 Hayden

    P2L Jedi

  • Members
  • PipPipPip
  • 716 posts
  • Gender:Male
  • Location:Texas

Posted 04 May 2006 - 08:41 PM

View Postrc69, on May 4 2006, 08:05 PM, said:

you've got to add the query string to the send() function just as you would in the url.
xmlhttp.Open("POST", "http://www.boothelp.us/bbcode_backend.php", false);
xmlhttp.Send("bbcode="+str);

i did that exact thing except without the quotes. i'll have to try that. thanks





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users