Results 1 to 3 of 3
  1.    #1  
    Newbie with what I assume is a really simple question for the experts here. I got my AJAX request to get my data from a website in the format:
    [ ["name1", "status1", "date1"], ["name2", "status2", "date2"] ]

    And I have the code sample from the "data" program in the SDK:
    Code:
    AjaxGetAssistant.prototype.gotResults = function(transport) {
    	//console.log ("gotResults:" + transport.responseText);
    	var r = transport.responseJSON;
    	this.resultsModel.items = $A(r.responseData.results);
    	this.controller.modelChanged(this.resultsModel);
    }
    I figured out that transport.responseText contain the raw data but after that I got lost. What is in variable "r"? How do I access my json data?

    Any help would be appreciated and if (or when) I ever get to the point where I can help somebody else, I will pay forward with what I can.
  2. #2  
    that isn't json data.

    That is an array. Json data would have been of the form:

    {Clirec: {Name: "name1", status: "stat1", date: "Date1"}, Clirec: {Name: "name2", status: "stat2", date: "Date2"}}

    but that isn't what you have.

    So, since you have a string representation of an array, do this:

    assume that your return string (from the ajax call is in returnString. so

    returnString = '[ ["name1", "status1", "date1"], ["name2", "status2", "date2"] ]'

    then what you would do is:

    returnedData = eval(returnString);

    var vname1 = returnedData[1] [1];
    var vstat1 = returnedData[1] [2];
    var vdate1 = returnedData[1] [3];

    var vname2 = returnedData[2] [1];
    var vstat2 = returnedData[2] [2];
    var vdate2 = returnedData[2] [3];

    What you got was an ARRAY -- not a json object.
  3.    #3  
    That worked perfectly. Thanks so much for your help. I didn't even realize that my code to generate JSON via PHP wasn't even correct until you pointed it out. After doing some reading, I figured out what I was doing wrong on the server side.

Posting Permissions