我與jQuery Mobile的jQuery代碼,打其他服務器上的URL時,我看到這個錯誤:語法錯誤無效的標籤
Syntax Error Invalid Label
來源是:
$(document).ready(function(){
var location;
var starPrice;
var endPrice;
var beds;
var baths;
var typep;
$('#location').change(function(){
typep = $("input[name='type']:checked").val();
baths = $("input[name='baths']:checked").val();
beds = $("input[name='beds']:checked").val();
location = $('#location').val();
starPrice = $('#priceStart').val();
endPrice = $('#priceEnd').val();
$.ajax({
url: "/findListings",
data:{
limit: 10
},
dataType: "jsonp",
type : 'POST',
}).done(function(data) {
alert(data[0].ListingId);
});
});
});
你不能使用$(document).ready(function(){with jQuery Mobile。它通常會在頁面DOM準備好之前觸發。如果DOM沒有準備好,你不能改變它。更多地瞭解它在這裏:http://stackoverflow.com/a/14469041/1848600。加上POST不能用於jsonp,它必須是GET。 – Gajotres 2013-03-14 14:09:32
我認爲它的語法錯誤...有沒有像Sintax ..:D – Ronnie 2013-03-14 14:11:42