<code>public function autorun(){ $uid = session('uid'); $map['pid'] = $uid; $User = M('land'); $data = $User->field('land')->where($map)->select(); print_r($data); //$this -> ajaxReturn($data); } </code>
<code> print_r($data); Array ( [0] => Array ( [land] => 1 ) [1] => Array ( [land] => 2 ) ) //可能会有更多数据</code>
Please tell me how to write ajaxReturn in the brackets. In the past, it was a one-dimensional array and it was one. This won't happen. What the frontend receives is the value in [land]. If multiple values are received, how does jquery separate these values.
<code>public function autorun(){ $uid = session('uid'); $map['pid'] = $uid; $User = M('land'); $data = $User->field('land')->where($map)->select(); print_r($data); //$this -> ajaxReturn($data); } </code>
<code> print_r($data); Array ( [0] => Array ( [land] => 1 ) [1] => Array ( [land] => 2 ) ) //可能会有更多数据</code>
Please tell me how to write ajaxReturn in the brackets. In the past, it was always a one-dimensional array and it was one. This won't happen. What the frontend receives is the value in [land]. If multiple values are received, how can jquery separate these values.
<code class="javascript">$.get(url, {}, function(d){ if ($.isArray(d)) { $.each(d, function(i, v){ $('.demo').append(v); }) } }, 'json');</code>
<code> $.ajax( url: url, type: "get", dataType: "json", success:function(data) { for(var i in data){ var obj = data[i]; console.log(obj.land); } } );</code>