1
我有這樣的代碼爲什麼這個jQuery不會觸發.ajax()請求?
// jquery
$(document).ready(function() {
$('#update_point').live("change", function() {
var point_val = $('#update_point').val();
$.ajax({
url: 'send/user/update_point.php',
type: 'get',
data: 'point='+point_val,
dataType: 'json',
success: function(data){
alert(data);
$('#update_point_result').html(data);
}
});
return false;
});
});
爲什麼代碼不被炒魷魚嗎?但如果我刪除dataType,代碼的作品。爲什麼?
// jquery
$(document).ready(function() {
$('#update_point').live("change", function() {
var point_val = $('#update_point').val();
$.ajax({
url: 'send/user/update_point.php',
type: 'get',
data: 'point='+point_val,
success: function(data){
alert(data);
$('#update_point_result').html(data);
}
});
return false;
});
});
任何幫助將appreaciate它! 謝謝!
編輯
update_point.php包含此代碼。
<?php
require "../../inc/json.php";
if($_GET){
foreach($_GET as $key=>$val){
$respon[$key] = $val;
}
}
// initialitation json object
$json = new Json();
echo $json->encode($respon);
die();
?>
返回我的警報「的翻譯:」爲什麼? –
我不確定。很確定你的問題是形成糟糕的JSON。正如我所說的,通過JSONlint來找出問題所在。 – karim79