Search code examples
javascriptmootoolsxmlhttprequest

how to use xmlhttprequest object's post method for sending data


I want to send data that is in a java script variable to the server.the variable is in a method that is executing when I click a button on the web site.here is the code written in that method for sending data.

    var xmlhttp;
if (window.XMLHttpRequest)
  {// code for IE7+, Firefox, Chrome, Opera, Safari
  xmlhttp=new XMLHttpRequest();
  }
else
  {// code for IE6, IE5
  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
xmlhttp.open("POST","new_map.php",true);
xmlhttp.send(cur_entry_string);

and here is code written in new_map.php file for getting data.here cur_entry_string is the variable that is holding that data.

$massage = $_POST[cur_entry_string];

but this is not working..:(...I am using eclipse.


Solution

  • Maybe you should have a look at an AJAX tutorial http://www.w3schools.com/ajax/default.asp and if that is not what you want to do you can also look into JSON