Hi everyone,

I'm new to Mootools, i try to use JSON to get data from a server.

I made a little CGI which send this when i call it :
    printf("Content-Type: application/json\n\n{\"data\":[\n{\n\"x1\":
159,\n\"y1\": 1110,\n\"width\": 840,\n\"height\": 2412\n},\n{\n\"x1\":
180,\n\"y1\": 3540,\n\"width\": 828,\n\"height\": 1077}]}");

And then i use the following function :

  /* Use a AJAX request to get the article
   */
  loadArticle: function(){
    var request =new Request.JSON(
    {
        url: this.serverXml,
        onComplete: function(response)
        {
            alert(response.data);
        },
        onFailure: function(){ alert('Unable to get image and tile sizes from
server!'); }
    } ).send();
  },

But it doesn't seem to work. When i use a simple Request, i get
correctly the stream.
I thought that my JSON source was incorrect so i made a simple JSON
file which contains the following code :

{
"data":[
        {
        "x1": 159,
        "y1": 1110,
        "width": 840,
        "height": 2412
        },
        {
        "x1": 180,
        "y1": 3540,
        "width": 828,
        "height": 1077
        }
       ]
}

I used the same function, but result is the same ... nothing. I check
with online validators and both file and json strings seems to be
ok ... Where is my mistake ?

Thanks in advance !

Reply via email to