More JSON Samples

This example calls the noParam function which invokes a server-side JSON call that then calls a handler back in the browser.
The client-side JavaScript for looks like:
    <script>
      // <![CDATA[
        function callNoParam() {
          noParam("noParamCallback");
        }

        function noParamCallback() {
          alert("the server called me back... woo hoo!");
        }
      // ]]>
    </script>

Let's send the contents of a test field and process it:

The Script to do this is:
    <script>
      // <![CDATA[
        function stringSender() {
          var q = jQuery("#myField")[0];
          var v = q.value;
          oneString("stringCallback", v);
        }

        function stringCallback(what) {
          jQuery("#dest")[0].innerHTML = "The server said: "+what;
        }
      // ]]>
    </script>

Let's send some numbers to the server and have the server add 1 to each of the numbers.
Enter comma separated numbers:

The server-side code looks like:
  new JsonHandler {
    def apply(in: Any): JsCmd = in match {
      case JsonCmd("noParam", resp, _, _) =>
        Call(resp)
        
      case JsonCmd("oneString", resp, XString(s), _) =>
        Call(resp, s)
        
      case JsonCmd("addOne", resp, XArrayNum(an), _) =>
        Call(resp, JsArray(an.map(n => Num(n.doubleValue + 1.0)) :_*))
        
      case _ => Noop
    }
  }