我需要在下面打印我的函数数据,到目前为止,我试图像$.each(data.data, function(key, value) {
一样将它放在循环中,也尝试直接获得结果,如data.price
或data['price']
偶数{{1无效,返回+ price +
。
undefined
script
function myfunction(){
$.ajaxSetup({
headers: { 'X-CSRF-TOKEN': $('meta[name="_token"]').attr('content') }
});
var cityname = $("#city option:selected").text();
cityname = cityname.substring(cityname.indexOf("-")+2);
var statename = $("#province option:selected").text();
if(statename && cityname) {
console.log(statename + " - " + cityname);
$.ajax({
url: '{{ url('getcityandstate') }}/' + statename + '/' + cityname,
type: "GET",
dataType: "json",
success:function(data) {
console.log(data);
// $('select[name="postchoose"]').append('<option id="postchoose" class="form-control" value="'+ price +'">'+ title +'</option>');
}
});
}
};
results
这是我的控制器
[…]
0: {…}
cart_amount: null
city: "Pandeglang"
created_at: "2018-03-23 12:19:28"
id: 6
price: "20"
state: "Banten"
title: "gfgg"
updated_at: "2018-03-23 12:24:47"
__proto__: Object { … }
length: 1
__proto__: Array []