現在1.4.4を使用しているサイトでjQuery1.7.2に移行する必要があります。以下のajax呼び出しがありますが、1.4.4では正常に機能しますが、キックバックしています
テキストから[オブジェクトへの変換なし
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
どんな助けでも大歓迎です。