为什么jquery赢了';t trigger.ajax()请求?
我有这个密码为什么jquery赢了';t trigger.ajax()请求?,jquery,ajax,types,response,Jquery,Ajax,Types,Response,我有这个密码 // jquery $(document).ready(function() { $('#update_point').live("change", function() { var point_val = $('#update_point').val(); $.ajax({ url: 'send/user/update_point.php', type: 'get',
// 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;
});
});
为什么代码没有被触发?但是如果我要删除数据类型,代码就会工作。为什么?
// 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;
});
});
任何帮助都会得到报答!
谢谢
编辑 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格式不正确时,ajax
喜欢默默地失败。使用诸如的工具检查来自服务器的JSON格式是否正确
您可以使用检查引发的错误类型:
$.ajax({
url: 'send/user/update_point.php',
type: 'get',
data: 'point='+point_val,
success: function(data){
alert(data);
$('#update_point_result').html(data);
},
error: function(jqXHR, textStatus, errorThrown) {
alert(errorThrown); // likely 'parseError'
}
});
$.ajax
喜欢在JSON格式错误时默默失败。使用诸如的工具检查来自服务器的JSON格式是否正确
您可以使用检查引发的错误类型:
$.ajax({
url: 'send/user/update_point.php',
type: 'get',
data: 'point='+point_val,
success: function(data){
alert(data);
$('#update_point_result').html(data);
},
error: function(jqXHR, textStatus, errorThrown) {
alert(errorThrown); // likely 'parseError'
}
});
给我一个警告“[对象]”为什么?我不确定。很确定你的问题是格式错误的JSON。正如我所说,通过JSONlint查找问题所在。返回警报“[object]”为什么?我不确定。很确定你的问题是格式错误的JSON。正如我所说,通过JSONlint查找问题所在。