1. var http = getHTTPObject();
  2.  
  3. function getHTTPObject() {
  4. if( window.XMLHttpRequest )
  5. return new window.XMLHttpRequest;
  6. else {
  7. try {
  8. return new ActiveXObject( "MSXML2.XMLHTTP.3.0" );
  9. }
  10. catch( ex ) {
  11. return null;
  12. }
  13. }
  14. }
  15.  
  16. function doMath() {
  17. var url = "1fix.php?op=" + document.getElementById('op').value;
  18. url += "&num1=" + document.getElementById('num1').value;
  19. url += "&num2=" + document.getElementById('num2').value;
  20.  
  21. http.open("GET", url, true);
  22. http.onreadystatechange = handleHttpResponse;
  23.  
  24. http.send(null);
  25. }
  26.  
  27. function handleHttpResponse() {
  28. if( http.readyState == 4 ) {
  29. document.getElementById('answer').innerHTML = http.responseText;
  30. }
  31. }