-1

Possible Duplicate:
Passing multiple parameter to PHP from Javascript

I am currently trying to pass data from Javascript to PHP. I have the PHP script is accessed from the Javascript except no information is stored in the $_Post variable. I even tried the $_Get and the $_Request to make sure it was not stored there. It was not. Can someone please help me? The function that I am using is below. The variable str is a string of things that I create elsewhere in the javascript that I feel as though are not useful to see. They are not gotten from an HTML form. The PHP script is also below.
Thanks

Javascript function that is supposed to do the passing of information.

function postForm(str) {
  var xmlHttp;
  try
    {    // Firefox, Opera 8.0+, Safari
     xmlHttp=new XMLHttpRequest();
    }
    catch (e)
    {    // Internet Explorer    
      try
      {
       xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");      
      } catch (e)
        {      
         try
         {
          xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
         } catch (e)
           {       
             alert("ERROR: CAN NOT POST DATA");
           }
        }
    }

    try 
    {
      xmlHttp.onreadystatechange=function()
      {
      if(xmlHttp.readyState==4)
        {
         alert(xmlHttp.responseText);
        }
      }
       xmlHttp.open("POST","BigInt2.php",true);
       postStr = "msg="+escape(str);
       alert("SENDING: "+postStr);
       xmlHttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
       xmlHttp.send(postStr);
    } catch(e)
      {
       alert("ERROR POSTING DATA");
      } 

}

PHP function that is supposed to do the printing of infomration as a proof of concept that the information is stored in the $_Post global variable. BigInt2.php

<?php
echo$_Post['msg'];
echo$_Get['msg'];
echo$_Request['msg'];
?>
2
  • 3
    Unless there's a specific reason you don't want to.. use jQuery. It makes this stuff so much simpler. Commented Apr 14, 2012 at 16:09
  • 1
    its POST and GET ..not Post and Get Commented Apr 14, 2012 at 16:11

1 Answer 1

4

You're mistyping (post and get) try this in your php file and see if it works

echo $_POST['msg'];
Sign up to request clarification or add additional context in comments.

1 Comment

Oops...I had a senior moment there haha

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.