AJAX Page - Type preserve

The parameters sent from server to client are keeping their type (bool, int, string, collection).


Make a callback to the server.

        ob_post.post(null, 'myServerMethod');
Server is returning an array of different value types.

        // array list
        public ArrayList myServerMethod1()
            // add different types of elements to an arraylist
            ArrayList al = new ArrayList();
            al.Add(new string[]{"x", "y", "z"});
            al.Add(new int[]{2, 3, 4, 5});
            al.Add(new bool[]{true, false});


            return al;
        // associative array
        public Hashtable myServerMethod2()
            // add different types of elements using a name-value pair collection
            Hashtable ht = new Hashtable();
            ht.Add("color", "red");
            ht.Add("sales", 21331218);
            ht.Add("isAsociative", true);


            return ht;
Script function, triggered by ExecBeforeLoad method, is looping through the response object items.
They preserve their types at client.

        // client function triggered in ExecBeforeLoad method
        function myFunction(response)
            for (key in response.content)
                var value = response.content[key];
                var valueType = typeof response.content[key];
                // process data
                // ...
Array List


For more information about the response object please check the client documentation.
See also: ExecBeforeLoad tutorial.