Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/node.js/38.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jsf-2/2.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
如何将javascript数组传递给jade模板?玉书_Javascript_Node.js_Ajax_Express - Fatal编程技术网

如何将javascript数组传递给jade模板?玉书

如何将javascript数组传递给jade模板?玉书,javascript,node.js,ajax,express,Javascript,Node.js,Ajax,Express,这是我的下拉列表 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调用, 剧本 函数js

这是我的下拉列表

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调用, 剧本 函数jsFunction(){ var client=document.getElementById('drop_client'); var c_name=client.options[client.selectedIndex].text; 变量数据={}; 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'数组。我如何访问它?

尝试声明var b_name=[];在ajax调用之外,没有兄弟..不工作!