Jquery - Uncaught TypeError: Cannot use 'in' operator to search for '324' in Jquery - Uncaught TypeError: Cannot use 'in' operator to search for '324' in php php

Jquery - Uncaught TypeError: Cannot use 'in' operator to search for '324' in


You have a JSON string, not an object. Tell jQuery that you expect a JSON response and it will parse it for you. Either use $.getJSON instead of $.get, or pass the dataType argument to $.get:

$.get(    'index.php?r=admin/post/ajax',    {"parentCatId":parentCatId},    function(data){                             $.each(data, function(key, value){            console.log(key + ":" + value)        })    },    'json');


You can also use $.parseJSON(data) that will explicit convert a string thats come from a PHP script to a real JSON array.


If you're fetching JSON, use $.getJSON() so it automatically converts the JSON to a JS Object.