|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Strict//EN">
<html>
<head>
<title>Prime factors calculator using AJAX</title>
<script type="text/javascript" src="ajax.js"></script>
<script type="text/javascript" src="GetJavaScriptProxy.aspx?service=CalcService.asmx"></script>
</head>
<body>
<h1>Prime factors calculator</h1>
<table>
<tbody>
<tr>
<th><label for="inputField">Please enter a number:</label></th>
<td>
<input id="inputField" onkeyup="ajax.Start(action1)"></td>
<td style="padding-left: 12px">
<button onclick="proxies.EnableCache(proxies.CalcService.CalcPrimeFactors)">enable caching</button></td>
</tr>
<tr>
<th><label>The factors are:</label></th>
<td>
<input id="outputField" size="60" disabled="disabled"></td>
</tr>
</tbody>
</table>
<h3>Hint:</h3>
<p>try 12313123123123 or 12313123123123123123 for long running calculations ! </p>
<script defer="defer" type="text/javascript">
// to set up a debug output in an alert box use:
// proxies.CalcService.CalcPrimeFactors.corefunc = proxies.alertResult;
// to set up a debug output of the http response body in an alert box use:
// proxies.CalcService.CalcPrimeFactors.corefunc = proxies.alertResponseText;
// attach window.alert for displaying result to make the direct webservice call asynchronous
// proxies.CalcService.CalcPrimeFactors.func = window.alert;
// alert any exceptions...
// proxies.CalcService.CalcPrimeFactors.onException = proxies.alertException;
// declare an AJAX action
var action1 = {
delay: 200,
prepare: function() { return (document.getElementById("inputField").value); },
call: proxies.CalcService.CalcPrimeFactors,
finish: function (p) { document.getElementById("outputField").value = p; },
onException: ajax.alertException
} // action1
</script>
<hr />
<p>This sample uses the AJAX Engine on the client to call a WebService that calculates the prime numbers
of a given number.</p>
<p>This page is part of the <a href="http://ajaxaspects.blogspot.com/">http://ajaxaspects.blogspot.com/</a>
project.</p>
<hr />
</body>
</html>
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.