我需要在当前使用1.4.4的网站上转移到jQuery 1.7.2。我有下面的ajax调用,它在1.4.4中正常工作,但正在反弹
No conversion from text to [object
在1.7.2。 (我认为这更多与.parseJSON()有关,但我不确定。)
function ajax_update(table_value, key_value, value_value, newkey_value, newvalue_value, debug) {
$.ajax({
type: "POST",
url: "/index.php/ajax/updatepost/",
data: {
table: table_value,
key: key_value,
value: value_value,
newkey: newkey_value,
newvalue: newvalue_value
},
dataType: JSON,
success: function(data, textStatus){
var result = jQuery.parseJSON(data);
//both debug and flash going in two different directions
$("div#flash > p").text(result.message);
$("div#flash").removeClass().addClass("message").addClass(result.flavor).slideDown(500).delay(1200).slideUp(500);
if (debug == true) {
$("div#debugflash > p").text(result.debug);
$("div#debugflash").removeClass().addClass("message").addClass("information").show();
}
},
error: function(errorObj, textStatus, errorThrown){
$("div#flash > p").text(errorThrown);
$("div#flash").removeClass().addClass("message").addClass("error").slideDown(500).delay(1200).slideUp(500);
if (debug == true) {
$("div#debugflash > p").text(errorThrown);
$("div#debugflash").removeClass().addClass("message").addClass("information").show();
}
}
});}
json在jsonlint.com中验证,由调用json_encode(array)的php脚本生成,如下所示:
{"message":"Updated field name with value ALAMO",
"flavor":"success",
"debug":"UPDATE `customers` SET `name` = 'ALAMO' WHERE `cust_id` = 'ALA100'"}
头:
HTTP/1.1 200 OK
Date: Tue, 01 May 2012 00:00:15 GMT
Server: Apache/2.2.21 (Unix) mod_ssl/2.2.21 OpenSSL/0.9.8r DAV/2 PHP/5.3.8 with Suhosin-Patch
X-Powered-By: PHP/5.3.8
Expires: Thu, 19 Nov 1981 08:52:00 GMT
Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0
Pragma: no-cache
MS-Author-Via: DAV
Content-Length: 177
Keep-Alive: timeout=15, max=96
Connection: Keep-Alive
Content-Type: application/json任何帮助深表感谢。