Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/loops/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
Typeahead.js 如何更改URL?_Typeahead.js_Typeahead_Bootstrap Typeahead - Fatal编程技术网

Typeahead.js 如何更改URL?

Typeahead.js 如何更改URL?,typeahead.js,typeahead,bootstrap-typeahead,Typeahead.js,Typeahead,Bootstrap Typeahead,这是我的JS脚本 function fillCities(country) { console.log('fillCities', country); var url = 'ajax.php?action=getVilles&country='+country+'&ville=%QUERY'; console.log('url', url); $('#city').typeahead('destroy'); $('#city').t

这是我的JS脚本

function fillCities(country) {
    console.log('fillCities', country);
    var url = 'ajax.php?action=getVilles&country='+country+'&ville=%QUERY';
    console.log('url', url);
    $('#city').typeahead('destroy');    
    $('#city').typeahead({
        name : 'city',    
        displayKey: 'city',
        valueKey: 'city',
        limit:10,
        cache: false,
        minLength:3,
        remote: {
            url : url
        }
    });
}
问题是:当国家/地区发生变化时,typeahead总是请求相同的url,而不会更改url

如何动态更改URL(URL中的国家参数)