The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums JavaScript [Solved] JQuery and JSON help

  • This topic is empty.
Viewing 1 post (of 1 total)
  • Author
  • #27904

    I hope someone can help me, I have an AJAX call which loads some data from a database and returns it as JSON. The code I use is:

    type: “POST”,
    url: “ajaxhandler.php”,
    data: “action=svgjson”,
    datatype: “json”,
    success: function(json){

    This works fine and returns the JSON and dumps the lot in the browser. However, I am having trouble parsing the file and getting the details I want from it. The file is structured as so:

    “use”:”Store Room”,

    Say I want to get the colour for each floorplan item. How do I go about doing this? I was thinking something like:


    But it just returns the error

    TypeError: Result of expression ‘json.floorplan’ [undefined] is not an object.

    Any help is much appreciated!

    EDIT: Never mind, fixed it myself. Apparently it was returning a string not an object so I had to use the eval() function to convert the string to an object. Now works perfectly!

Viewing 1 post (of 1 total)
  • The forum ‘JavaScript’ is closed to new topics and replies.