Twitter bootstrap 需要关于使用ajax源代码的multiselect for bootstrap typehead的帮助吗?
我想用bootstrap字体自动填充,但我有点困惑,我用的是下面的JS,任何人都可以帮我。 我的要求是: 任何用户使用打字机填写的内容都应该进入textarea($myTextarea) 我想将选定的值放入文本区域Twitter bootstrap 需要关于使用ajax源代码的multiselect for bootstrap typehead的帮助吗?,twitter-bootstrap,bootstrap-typeahead,Twitter Bootstrap,Bootstrap Typeahead,我想用bootstrap字体自动填充,但我有点困惑,我用的是下面的JS,任何人都可以帮我。 我的要求是: 任何用户使用打字机填写的内容都应该进入textarea($myTextarea) 我想将选定的值放入文本区域 $(document).ready(function() { $('input.typeahead').typeahead({ source: function (query, process) { $.ajax({ url: '/test/typehead/data.php', t
$(document).ready(function() {
$('input.typeahead').typeahead({
source: function (query, process) {
$.ajax({
url: '/test/typehead/data.php',
type: 'POST',
dataType: 'JSON',
data: 'query=' + query,
success: function(data) {
console.log(data);
process(data);
}
});
}
});
updater: function(item) {
$myTextarea.append(item, ' ');
return '';
}
});
谢谢,
Ashok已解决…某些语法错误
$(document).ready(function() {
var $myTextarea = $('#myTextarea');
$('input.typeahead').typeahead({
source: function (query, process) {
$.ajax({
url: '/test/typehead/data.php',
type: 'POST',
dataType: 'JSON',
data: 'query=' + query,
success: function(data) {
console.log(data);
process(data);
}
});
},
updater: function(item) {
$myTextarea.append(item, ' ');
return '';
}
});
});
这应该对你有所帮助,
进一步阅读请阅读
干杯
jQuery(function ($) {
$('.typeahead').typeahead({
source: function (query, process) {
return $.ajax({
type: "POST",
contentType: "application/json; charset=utf-8",
url: "url",
data: '{ "query": "' + query + '"}',
dataType: "json",
success: function (data) {
//use data.d in case of asp.net
return process(data);
},
failure: function (response) {
alert("Failure");
},
error: function (jqXHR, textStatus, errorThrown) {
alert("There seems to be an error");
}
});
},
updater: function(item) {
$myTextarea.append(item, ' ');
return item;
}
});
});