Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/369.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 正在尝试检索';术语';自动完成中某个回调函数中的参数_Javascript_Jquery_Jquery Ui_Magento_Client Side - Fatal编程技术网

Javascript 正在尝试检索';术语';自动完成中某个回调函数中的参数

Javascript 正在尝试检索';术语';自动完成中某个回调函数中的参数,javascript,jquery,jquery-ui,magento,client-side,Javascript,Jquery,Jquery Ui,Magento,Client Side,我有以下javascript代码-我想在onSelect()回调函数中使用'term'$\u GET变量 谁能解释一下我是怎么做到的?我尝试在回调中使用console.log,但这似乎不起作用 $('#org_search_term, #org_search_postcode').autocomplete({ serviceUrl: '<?php echo $this->getUrl('rp/organisation/search', array('_secure' =>

我有以下javascript代码-我想在onSelect()回调函数中使用'term'$\u GET变量

谁能解释一下我是怎么做到的?我尝试在回调中使用console.log,但这似乎不起作用

$('#org_search_term, #org_search_postcode').autocomplete({
    serviceUrl: '<?php echo $this->getUrl('rp/organisation/search', array('_secure' => true)) ?>',
    paramName:'term',
    minChars: 3,
    deferRequestBy: 500,
    dataType: 'json',
    onSearchStart: function(){
        $('#org_search_term, #org_search_postcode').addClass('loading');
    },
    onSearchComplete: function(){
        $('#org_search_term, #org_search_postcode').removeClass('loading');
    },
    onSearchError: function(){
        $('#org_search_term, #org_search_postcode').removeClass('loading');
    },
    onSelect: function(selected, data) {
      console.log(this); // this doesn't seem to work
    },
    transformResult: function (response) {

        var results = { suggestions:[] };

        if (!response.totalRecords)
            return false;

        $.each(response.items, function(i, item){
            results.suggestions.push({
                value: item.organisation_name+', '+item.street+', '+item.town+', '+item.county+', '+item.postcode+', '+item.country,
                data:  item.organisation_id,
                organisation_name: item.organisation_name
            });
        });

        // add the catch all result
        results.suggestions.push({
            value: '<?php echo $this->__('My org is not listed') ?>',
            data: null,
            organisation_name: null
        });

        return results;
    }
});
$('org\u search\u term,'org\u search\u postcode')。自动完成({
服务URL:“”,
参数名称:'term',
明查斯:3,
延期:500,
数据类型:“json”,
onSearchStart:function(){
$('org\u search\u term,'org\u search\u postcode').addClass('loading');
},
onSearchComplete:函数(){
$('org\u search\u term,'org\u search\u postcode').removeClass('loading');
},
onSearchError:function(){
$('org\u search\u term,'org\u search\u postcode').removeClass('loading');
},
onSelect:功能(已选,数据){
console.log(this);//这似乎不起作用
},
转换结果:功能(响应){
var结果={建议:[]};
if(!response.totalRecords)
返回false;
$.each(response.items,function(i,item){
结果、建议、推动({
值:item.organization_name+'、'+item.street+'、'+item.town+'、'+item.country+'、'+item.postcode+'、'+item.country、,
数据:项目组织机构id,
组织名称:项目。组织名称
});
});
//添加catch all结果
结果、建议、推动({
值:“”,
数据:空,
机构名称:空
});
返回结果;
}
});
看一看@

select: function (event, ui) {
    var label = ui.item.label;
    var value = ui.item.value;
}