【发布时间】:2009-10-11 15:50:10
【问题描述】:
我无法让这个更新脚本在 IE 中运行。在其他所有浏览器中都可以正常工作。 IE 告诉我更新已执行。然而,事实并非如此。我没有更多的头发可以拔了..grr。顺便说一句,我也试过$.ajax 和$.get .. 仍然没有运气。我认为这可能与live 点击处理程序有关。不知道...我已经尝试了一切...(将标头放置为无缓存,在我的 url 字符串的末尾附加一个随机数)...没有任何效果...炸毁 IE。
这是我正在使用的$('.save').live('click') 函数:
$(".save").live("click", function(){
$.post("update.php", { cache : false, saveID : saveIt.value, saveMo : saveMonth, saveYr : saveYear, saveCtg : saveCt, saveThg : saveTh },
function(data){
if(data.success) {
$(textareaThoughts).hide();
$(saveIt).parents(".dirRowOne").find(".cancel").hide();
$(saveIt).parents(".dirRowOne").find(".edit, .del").show();
$(saveIt).hide();
$("#dirConsole").html(data.message);
} else if(data.error) {
}
}, "json");
return false;
});
这里是update.php
<?php
if($_POST) {
$data['id'] = $db->escape_value($_POST['saveID']);
$data['months'] = trim($db->escape_value($_POST['saveMo']));
$data['years'] = trim($db->escape_value($_POST['saveYr']));
$data['cottages'] = trim($db->escape_value($_POST['saveCtg']));
$data['thoughts'] = trim(htmlentities($db->escape_value($_POST['saveThg'])));
$id = $data['id'];
$m = $data['months'];
$y = $data['years'];
$c = $data['cottages'];
$t = $data['thoughts'];
$query = "UPDATE //tablename SET month = '{$m}', year = '{$y}', cottage = '{$c}', thoughts = '{$t}' WHERE dirID = '{$id}'";
$result = $db->query($query);
if($result) {
$data['success'] = true;
$data['message'] = "Update Successful!";
} else {
$data['error'] = true;
}
echo json_encode($data);
}
?>
这是 JSON 响应:
{"id":"360","months":"June","years":"1990","cottages":"Cedar","thoughts":"Hello","success":true,"message":"Update Successful!"}
【问题讨论】:
-
它不会在 IE7 中执行更新。但它在 Firefox、Opera、Chrome 和 Safari 中确实如此。
-
你不只是喜欢让事情在 IE 中运行吗?
-
@Matt Ball => 不,我不知道 :) 我的意思是来吧,已经够了。死吧,死吧,死吧,死吧!!!!!!
标签: jquery ajax json internet-explorer-7