Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <script type="text/javascript">
- function calculateNum(n, r)
- {
- var hasVal = false;
- var number = n;
- var result = r;
- if(window.XMLHttpRequest)// code for IE7+, Firefox, Chrome, Opera, Safari
- xmlhttp=new XMLHttpRequest();
- else// code for IE6, IE5
- xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
- xmlhttp.onreadystatechange=function()
- {
- if(xmlhttp.readyState==4 && xmlhttp.status==200)
- {
- var next = xmlhttp.responseText;
- alert("got response of "+next);
- if(next == -1)
- alert("err");
- else
- return next;
- //hasVal = true;
- }
- }
- xmlhttp.open("GET","storeResults.php?n="+number+"&r="+result,false);
- xmlhttp.send();
- if(hasVal)
- return next;
- }
- </script>
- <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
- <title>Untitled Document</title>
- </head>
- <script type="text/javascript">
- var n = parseFloat(<?php echo $startWith ?>);
- var r = 1/n;
- var nextNum = calculateNum(n, r);
- alert("returned value of: "+nextNum);
- while(confirm("1 / "+n+" = "+r+"\nContinue?"))
- {
- n = nextNum;
- r = 1/n;
- nextNum = calculateNum(n, r);
- }
- alert("outside while loop");
- </script>
Advertisement
Add Comment
Please, Sign In to add comment