greenvrionmentalist

main file

May 10th, 2014
253
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.17 KB | None | 0 0
  1. <script type="text/javascript">
  2. function calculateNum(n, r)
  3. {
  4. var hasVal = false;
  5. var number = n;
  6. var result = r;
  7.  
  8. if(window.XMLHttpRequest)// code for IE7+, Firefox, Chrome, Opera, Safari
  9. xmlhttp=new XMLHttpRequest();
  10. else// code for IE6, IE5
  11. xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  12.  
  13. xmlhttp.onreadystatechange=function()
  14. {
  15. if(xmlhttp.readyState==4 && xmlhttp.status==200)
  16. {
  17. var next = xmlhttp.responseText;
  18. alert("got response of "+next);
  19. if(next == -1)
  20. alert("err");
  21. else
  22. return next;
  23. //hasVal = true;
  24. }
  25. }
  26. xmlhttp.open("GET","storeResults.php?n="+number+"&r="+result,false);
  27. xmlhttp.send();
  28.  
  29. if(hasVal)
  30. return next;
  31. }
  32. </script>
  33. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  34. <title>Untitled Document</title>
  35. </head>
  36. <script type="text/javascript">
  37. var n = parseFloat(<?php echo $startWith ?>);
  38. var r = 1/n;
  39. var nextNum = calculateNum(n, r);
  40. alert("returned value of: "+nextNum);
  41. while(confirm("1 / "+n+" = "+r+"\nContinue?"))
  42. {
  43. n = nextNum;
  44. r = 1/n;
  45. nextNum = calculateNum(n, r);
  46. }
  47. alert("outside while loop");
  48. </script>
Advertisement
Add Comment
Please, Sign In to add comment