skip to Main Content

I’ve been trying to get values from an ajax response — without any success, the closest I got was getting an array of undignified.

$.each(JSON.parse(response,function(i,value){console.log(value[1].buildings);}));

Here is a screenshot of my ajax response

ajax response screenshot

I need to store name + success:false + column + message to a variable as json

Thanks for your input!

2

Answers


  1. Please check your datatype for hasCircuit. It should be integer

    Login or Signup to reply.
  2. If you run the snippet below you can see that the fn variable is undefined. That’s why your array is undefined. Remove the callback function from your snippet and it should work.

    Solution:

    $.each(JSON.parse(response));
    
    const json = '{"result":true, "count":42}';
    const fn = JSON.parse(json, function(i, val) {
      console.log(i, val);
    });
    
    console.log('----');
    console.log(fn);
    
    const obj = JSON.parse(json);
    
    console.log(obj.count);
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search