这是我的下拉,
select.selectpicker(onchange='', id='drop_banch', data-live-search='true')
option(value='', disabled='', selected='') Select Branch
for result in '#{b_name}'
option(value='#{result.b_name}') #{result.b_name}
AJAX Call, 脚本。 function jsFunction(){ var client = document.getElementById(' drop_client'); var c_name = client.options [client.selectedIndex] .text; var data = {}; data.c_name = c_name;
$.ajax({
type: 'POST',
data: JSON.stringify(data),
contentType: 'application/json',
url: 'http://localhost:3000/dispatch_item',
success: function (data) {
console.log('success');
for (var k in data) {
var b_name = [];
b_name.push(data[k].client_name);
}
alert(JSON.stringify(data));
console.log(data);
console.log(JSON.stringify(data));
},
error: function () {
alert('Ajax error!');
console.log('process error');
}
});
我的问题是我无法使用' b_name'脚本外的数组。我该如何访问?