我已经花了几个小时,试图在我的“远程”路径中获取一个变量。这个变量将根据另一个输入而改变。这是代码:
school_value = $('#school').val();
$('#school').change(function () {
school_value = $(this).val();
$('#programme').typeahead('destroy'); // I have also tried with destroy - but it doesnt work.
});
$('#programme').typeahead({
remote: 'typeahead.php?programme&type=1&school_name=' + school_value,
cache: false,
limit: 10
});
变量“school_type”没有在远程地址中设置,因此没有被调用。你有什么线索可以让它工作吗?我刚从Bootstrap 2.3切换到3,然后注意到typeahead已经被弃用了。以上代码在Bootstrap 2.3上有效,但似乎当脚本初始化时,远程路径被锁定了。
'
,不像您代码中的其他部分需要反斜杠。 - Sergioschool_type
,但我没有看到它,我猜想这是你想在此请求中包含的其他字段。然而,你说它以前可以工作?这是关于做一些新事情还是修复更新后出现的问题? - Daveschool_value ='testing'
,那么它就完美地工作了。但当我在 #school 中输入内容时,它就无法更改。 - FooBar