【发布时间】:2013-01-11 23:21:18
【问题描述】:
我尝试使用 Ajax 做一个 twitter 引导字体,但没有任何反应。没有错误没有输出 这是我的 jquery ajax 代码
function CallData() {
$('input.typeahead.local.remote').typeahead({
source: function (typeahead,query) {
$.ajax({
type: "GET",
url: "http://cs-api-sandbox.herokuapp.com/v1/challenges/search?keyword=r&callback=my_callback",
jsonpCallback: "my_callback",
dataType: "jsonp",
error: function (xhr, errorType, exception) {
var errorMessage = exception || xhr.statusText;
alert("Excep:: " + exception + "Status:: " + xhr.statusText);
}
});
}
});
}
function my_callback(data) {
alert('hi');
}
这是我的html代码
<input type="text" id="txt" runat="server" class="span4 typeahead local remote" placeholder="Search..." />
我在每次按键时调用 ajax 函数 CallData(),但没有任何反应
【问题讨论】:
-
是否会触发任何
alert()调用? -
不,它不会被触发
标签: javascript jquery ajax bootstrap-typeahead