[英]phonegap ajax not working with value
<script>
$(document).ready(function() {
$.ajax({url: "http://somedomain/app/district.php", success: function(result){
$("#district").html(result);
}});
$.ajax({url: "http://somedomain/app/category.php", success: function(result){
$("#crop-category").html(result);
}});
$('#district').change(function(){
var value=$('#district').val();
$('#upazila').parent().find('span').html("<span> </span>");
$.ajax({
url: "http://somedomain/app/upazila.php",
type: "get", //send it through get method
data:{value},
success: function(response) {
$("#upazila").html(response);
},
error: function(xhr) {
//Do Something to handle error
}
});
});
});
</script>
這是我的jquery代碼,即時消息我為Android構建了一個應用程序。 對於前兩個ajax請求,我得到了值,但是當我通過get請求傳遞一些變量時,該代碼不起作用。 在調試狀態下,它說出Uncaught SyntaxError:Unexpected token} index.html:36這是
數據:{value},
但它在瀏覽器上工作正常...請幫助。
問題是在您的第三個ajax
調用中, data
字段不是有效的對象, data
應該是object,string或Array 。 傳遞如下所示的value
:
data: value
您無需在花括號內提及它。 或者,如果它是字符串或數組,並且希望將其作為對象傳遞,則按如下所示傳遞它:
data: {value: value}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.