Q:

Proplem with get element id ( Uncaught TypeError: Cannot set property 'innerHTML' of null )

i want to get some value from div and send it to database, i wrote it and it worked at my localhost but when i uploaded source on my host it stopped working...
this error i get in console
Uncaught TypeError: Cannot set property 'innerHTML' of null index.php:700
request.onreadystatechange

ajax on same page where divs are
   <script type="text/javascript">
// create the XMLHttpRequest object, according browser
function get_XmlHttp() {
  // create the variable that will contain the instance of the XMLHttpRequest object (initially with null value)
  var xmlHttp = null;

  if(window.XMLHttpRequest) {       // for Forefox, IE7+, Opera, Safari, ...
    xmlHttp = new XMLHttpRequest();
  }
  else if(window.ActiveXObject) {   // for Internet Explorer 5 or 6
    xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
  }

  return xmlHttp;
}

// sends data to a php file, via POST, and displays the received answer
function ajaxrequest(php_file, tagID) {
  var request =  get_XmlHttp();     // call the function for the XMLHttpRequest instance

  // create pairs index=value with data that must be sent to server
  var  the_data = 'pg='+document.getElementById('template').innerHTML;
  var  the_data2 = 'memid='+document.getElementById('memid').innerHTML;
  var  the_data3 = 'proid='+document.getElementById('proid').innerHTML;
  var  the_data4 = 'taipei='+document.getElementById('taipei').innerHTML;

  request.open("POST", php_file, true);         // set the request

  // adds  a header to tell the PHP script to recognize the data as is sent via POST
  request.setRequestHeader("Content-type", "application/x-www-form-urlencoded");

  var post_data = the_data + '&' + the_data2 + '&' + the_data3 + '&' + the_data4;

  request.send(post_data);      // calls the send() method with datas as parameter
  // Check request status
  // If the response is received completely, will be transferred to the HTML tag with tagID
  request.onreadystatechange = function() {
    if (request.readyState == 4) {
      document.getElementById(tagID).innerHTML = request.responseText;
    }
  }
}
</script>

divs 
<div id="template"> some html here </div>
<div id="memid" style="display:none;">4</div>
<div id="proid" style="display:none;">55</div>
<div id="taipei" style="display:none;">sav</div>

button
<button value="sasasasasa" onclick="ajaxrequest('temp1.php', 'context')"></button>

A:

Assuming line 700 is
document.getElementById(tagID).innerHTML = request.responseText;

...then you clearly don't have an element with the id in tagID, which according to the example button you've shown, would be "context". And indeed, you haven't shown any HTML that defines an element with the id "context".

