我有奇怪的問題:jQuery的自動完成與JSON數據
首先,我有這樣的代碼:
var countries = dajjson();
$('#usluga').autocomplete({
lookup: countries,
onSelect: function (suggestion) {
alert('You selected: ' + suggestion.ID + ', ' + suggestion.naziv);
}
});
});
function dajjson() {
$.ajax({
url: "autoUsluge.php",
type: "POST",
async: true,
dataType: "html",
success: function(data) {
console.log(data);
},
error: function (data) {
console.log(data);
console.log('GRESKA NEKA');
}
});
};
我的JSON是 - 功能DAJJSON()的返回:
[{"ID":"4","naziv":"","opis":"Web dizajn","jmere":"komada","kol":"2","cena":"50","valuta":"Eur","popust":"5","porez":"20","user_id":"1"},{"ID":"5","naziv":"","opis":"Programiranje","jmere":"sati","kol":"5","cena":"10","valuta":"Eur","popust":"5","porez":"20","user_id":"1"},{"ID":"6","naziv":"","opis":"Popravka zadnjeg trapa na automobilu Audi","jmere":"komada","kol":"1","cena":"80","valuta":"Eur","popust":"5","porez":"20","user_id":"1"}]
,並在那裏我測試我剛剛得到的代碼:
Uncaught SyntaxError: Unexpected token <
'POST'是不提交數據的錯誤http操作...您可能想使用'GET'。這只是遵循HTTP規範。 – abc123
@ abc123我必須在以前的工作中與Oracle Application Express進行交互,並且它允許的唯一請求是「POST」。我同意你 - 按照規範隨時隨地......當它不可能時,它可能是一個絕對的噩夢.. –