JSONRequest

Hello,

Please, point me out to documentation, manual, examples of using the JSONRequest object and its functions.

The information found in the Reference is not sufficient and understandable without examples, which I did not find. There is a JSON file at examples/data/gridData.txt but I could not discover which example makes use of it.

When I try to use JSONRequest like:

JSONRequest.get('http://example.com/gridData.txt', jsonResult);

(replace example.com with your real host, e.g. localhost:8080)
I am getting nothing back. I cannot see even the first alert in the jsonResult function.

I can still read json with the usual xmlhttprequest as a text and eval() it but what the point of JSONRequest then?

P.S. JSONRequest does not support local files because file system does not return http OK status (200). However, the file is read but not evaluated due to the above reason.

P.S.S. It seams that the problem happens on line 214 in json.js. Unfortunately, the called function there does not return any exceptions and does not have any other (like initiating get request) visible for me effects.

If I use a protocol in a URI, e.g. http://..., the function seams do nothing . If I skip a protocol then the location is resolved to the local drive, which is not a correct destination neither.

using JSON library

image
Here it is code for your JSON test html page:

<html><head>
 <title> JSON test </title>
 <script type="text/javascript" src="/engine/lib/json.js"></script>
 </head>
<body>

<script type="text/javascript">
<!--
   try{
       // it throws an exception
       var iRequest = JSONRequest.get("http://nsk/test/json.php")
   } catch( err){
        console.dir( err)
   }
   //correct call
   var iRequest = JSONRequest.get("json.php",
        function(iRequestNumber, Data, Err){
            if(Err)
                console.warn( Err)
             else
                console.dir( Data)
        })
//-->

</script>
 </body>
</html>

Only acceptable content type is 'application/jsonrequest'

Here it is PHP test file(json.php):

<?php
header("Content-Type:application/jsonrequest");
?>

{"test_object" : "test response"}

JSON documentation

image
Here it standard API for JSONRequest
http://www.json.org/JSONRequest.html

Thanks for the intensive

Thanks for the intensive help;)

We have used json.org as a guidelines for our previous version of a product but apparently not fully followed the standard.