• Home
  • How to manipulate JSON ResponseText in EXTJS

  • I have used the EXT.data.request to try to get text from a webpage with the following content:
    [{"brand":null,"remark":null,"type":null,"id":120,"shop":null,"price":null,"model":null}]

    The code I written to get the id value 120 is below:

    conn.request({
    url: 'json.htm',
    method: 'POST',
    success: function(response) {
    var jsonData = Ext.util.JSON.decode(response.responseText);
    alert(jsonData.id);
    }
    }); ....

    After testing the code in browser, I failed to get the expected result, anyone can help?


  • unwrap your json object from the array brackets. :)


  • your id is inside an array so try this.

    data[0].id;

    Here is a very good site about json, http://json.org/. Read on.


  • {"brand":null,"remark":null,"type":null,"id":120," shop":null,"price":null,"model":null}


  • Thanks, but the reason I asked was because I have something in the form:
    {"data": [{...}]}.

    This was initialliy written for a JsonStore but now I also need it for a plain AJAX request.

    I think it is more a syntax issue... I can't seem to figure out how to access the properties of "data".


  • unwrap your json object from the array brackets. :)

    Hello,

    Can you show a small example?


  • and jsonlint.com - to make sure your json is lint-tastic.







  • #If you have any other info about this subject , Please add it free.#
    Your name:
    E-mail:
    Telphone:

    Your comments:


    If you have any other info about How to manipulate JSON ResponseText in EXTJS , Please add it free.