Source Code

for file S02_AJAXCoreSamples/CalcFactorsAJAX.htm

<!DOCTYPE html>
<html lang="en">

  <title>Prime factors calculator using AJAX actions</title>
  <link href="/mathertel.css" rel="stylesheet" type="text/css" />
  <script type="text/javascript" src="/ajaxcore/ajax.js"></script>
  <script type="text/javascript" src="/ajaxcore/GetJavaScriptProxy.aspx?service=/AJAXEngine/S02_AJAXCoreSamples/CalcService.asmx"></script>
  // CalcFactorsAJAX.htm
  // Sample showing the usage of AJAX Actions.
  // Copyright (c) by Matthias Hertel,
  // This work is licensed under a BSD style license. See
  // -----
  // 18.11.2005 minor fix in layout.

  <a style="position: absolute; right: 32px; top: 10px" href="../ViewSrc.aspx">View Source</a>
  <h1>Prime factors calculator using AJAX actions</h1>
  <table style="table-layout: fixed; width: 620px">
        <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
        <th><label>The factors are:</label></th>
        <td colspan="2"><input id="outputField" size="60" disabled="disabled"></td>
  <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: proxies.alertException
} // action1

  <hr />
  <p>try 12313123123123 or 12313123123123123123 for long running calculations ! </p>
  <hr />
  <p>This sample uses HTML, Javascript and the XMLHTTP object on the client to call
    a WebService.</p>
  <p>This page is part of the <a href="">Aspects
    of AJAX</a> project.</p>
  <p>For updates and discussions see <a href=""></a>.</p>
  <hr />

This page is part of the web site.

For updates and discussions see