XMLHttpRequest передаёт переменную скрипту php

Я пытаюсь передать переменную в php-скрипт с использованием XMLHttpRequest, а затем вернуть php обратно. Я не понимаю, почему он не работает, может кто-то мне помочь. Вот Javascript.

<script language="javascript" type="text/javascript"> // Browser Support function Heatctrl(heatMode){ var heatControlRequest; try{ //Good Browsers heatControlRequest = new XMLHttpRequest(); } catch (e) { //Internet Explorer try{ heatControlRequest = new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) { try{ heatControlRequest = new ActiveXObject("Microsoft.XMLHTTP"); }catch (e) { alert("Brower not supported"); return false; } } } // Function to receive data from server and store in variable heatControlRequest.onreadystatechange = function(){ if (heatControlRequest.readystate == 4){ alert(heatControlRequest.responseText); //document.getElementById("controlMode").innerHTML=heatControlRequest.responseText; //var heatControlResponse = heatControlRequest.responseText; } } var url = "heatControl.php?heatmode="+heatMode; // Send the request heatControlRequest.open("GET", url, true); heatControlRequest.send(); } </script> 

HTML-код

  <div id="boilerButtons"> <button type="button" onclick="Heatctrl('On')">Heating On</button> <button type="button" onclick="Heatctrl('Off')">Heating Off</button> <button type="button" onclick="Heatctrl('Boost')">Boost</button> </div> 

и php

 <?php $controlMode = $_GET['heatmode']; echo $controlMode; ?> 

Любая помощь очень ценится, я работаю в электронике, а не в программировании, и я боролся с этим сейчас в течение двух дней.

Проблема в этой строке:

 if (heatControlRequest.readystate == 4){ ^ this should be an uppercase S 

Должен быть:

 if (heatControlRequest.readyState == 4){ 

Из документов :

Объект XMLHttpRequest может находиться в нескольких состояниях. Атрибут readyState должен возвращать текущее состояние.