我正在使用以下jQuery Ajax调用......无论如何它都无法正常工作。
错误:TypeError: a is null
这是我的代码:
var prefixUrl = "autocomplete?action=complete&id=";
$('#complete-field').bind('keyup', function(){
var url = prefixUrl + escape($('#complete-field').val());
$.ajax({
type: "GET",
getUrl:url,
dataType: "xml",
success: function(responseXML) {
var composers = responseXML.getElementsByTagName("composers")[0];
if (composers.childNodes.length > 0) {
$('#complete-table').css("border", "1px solid green");
$('#complete-table').css("margin", "128px 0 0 -82px");
for (var loop = 0; loop < composers.childNodes.length; loop++) {
var composer = composers.childNodes[loop];
var firstName = composer.getElementsByTagName("firstName")[0];
var lastName = composer.getElementsByTagName("lastName")[0];
var composerId = composer.getElementsByTagName("id")[0];
appendComposer(firstName.childNodes[0].nodeValue, lastName.childNodes[0].nodeValue, composerId.childNodes[0].nodeValue);
}
}
},
error:function (xhr, ajaxOptions, thrownError) {
alert('xhr.status: ' + xhr.status);
alert(thrownError);
}
});
});
有什么想法吗?
非常感谢
答案 0 :(得分:3)
$.ajax({
type: "GET",
getUrl:url,
...
应该是
$.ajax({
type: "GET",
url: url,
...
上的文档