我正在製作維基百科查看器,並且我實現了維基百科標題搜索ajax調用工作正常,直到我在輸入&按鈕標籤周圍添加了表單標籤。HTML會影響ajax調用
<form class="pure-form">
<input type="text" id="txtff" class="pure-input-rounded" placeholder="Search for...">
<button type="submit" class="pure-button"><span class="glyphicon glyphicon-search" aria-hidden="true"></span></button>
</form>
我的Ajax代碼是:
$("button").click(function() {
var url = "https://en.wikipedia.org/w/api.php?action=query&format=json&list=allpages&aplimit=5&apfrom=Albert";
$.ajax({
url: url,
jsonp: "callback",
dataType: "jsonp",
success: function(resp){
console.log(JSON.stringify(resp));
},
error: function(err){
console.log("ERR")
}
});
});
我在做這一切的codepen:http://codepen.io/theami_mj/pen/KMKPvZ
HTML不影響阿賈克斯。 – brk
什麼是錯誤? –