Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/74.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php Can';我不知道如何解析这些数据_Php_Jquery_Json - Fatal编程技术网

Php Can';我不知道如何解析这些数据

Php Can';我不知道如何解析这些数据,php,jquery,json,Php,Jquery,Json,我使用AJAX调用从PHP得到的响应: $.ajax({ url: 'getit.php', type: 'POST', dataType: 'json', data: {id_token: my_token}, success: function(data) { //stuff } }); 当我使用console.log时,会显示如下内容: email: "me@example.co" email_verified: true first_name: "Bob

我使用AJAX调用从PHP得到的响应:

$.ajax({
  url: 'getit.php',
  type: 'POST',
  dataType: 'json',
  data: {id_token: my_token},
  success: function(data) {
  //stuff
  }
  });
当我使用console.log时,会显示如下内容:

email: "me@example.co"
email_verified: true
first_name: "Bob"
permissions: Object
   client_1001: Object
      client_id: "121434"
      role: "full"
      table_name: "5tyyd"
   client_1002: Object
      client_id: "45638"
      role: "full"
      table_name: "df823"
如果我这样做:

$('.last_name').text(data.first_name);


我需要填写什么表格?部分它基本上是对象中的一个对象,但我不确定如何解析它。

在使用jQuery时,请尝试一下:

$.each(data.permissions, function (index, value) {
    console.log(index);            // "client_0001"
    console.log(value.table_name); // "5tyyd"
});
其思想是迭代响应,就像在PHP中使用foreach()一样。

可能重复的
$('.last_name').text(data.permissions.WHATGOESHERE?);
$.each(data.permissions, function (index, value) {
    console.log(index);            // "client_0001"
    console.log(value.table_name); // "5tyyd"
});