jQuery的$。员额更新不工作在IE浏览器 [英] jQuery $.post update not working in IE
问题描述
我不能得到这个更新脚本在IE工作。在其他浏览器工作正常。 IE浏览器告诉我,进行了更新。然而,事实并非如此。我没有更多的头发留下来拉out..grr。顺便说一句我试过$ $。获得
too..still没有运气。我想它可能有一些做的生活
单击处理程序。不知道......我已经竭尽所能。(把标头无缓存,同时附上一个随机数,以我的网址字符串的结尾)..没有fricken作品......轰出IE浏览器。
这是 $(保存。)生活(点击)
函数我使用的:
$(拯救)。生活(点击,函数(){
$。员额(update.php,{缓存:假的,saveID:saveIt.value,saveMo:saveMonth,saveYr:saveYear,saveCtg:saveCt,saveThg:午餐节省},
功能(数据){
如果(data.success){
$(textareaThoughts).hide();
$(saveIt)。家长(dirRowOne。)找到(取消),隐藏()。
$(saveIt)。家长(dirRowOne。)找到(编辑,.DEL。)显示()。
$(saveIt).hide();
$(#dirConsole)HTML(data.message)。
}否则,如果(data.error){
}
},JSON);
返回false;
});
这里的update.php
< PHP
如果($ _ POST){
$数据['身份证'] = $ DB-> escape_value($ _ POST ['saveID']);
$数据['月'] =修剪($ DB-> escape_value($ _ POST ['saveMo']));
$数据['年'] =修剪($ DB-> escape_value($ _ POST ['saveYr']));
$数据['小屋'] =修剪($ DB-> escape_value($ _ POST ['saveCtg']));
$数据['想法'] =修剪(ヶ辆($ DB-> escape_value($ _ POST ['saveThg'])));
的$ id = $数据['身份证'];
$ M = $数据['月'];
$ Y = $数据['年'];
$ C = $数据['小屋'];
$ T = $数据['想法'];
$查询=UPDATE //表名SET月='{$ M}',一年='{$ Y}',山寨='{$ C}',思想='{$ T}'WHERE DIRID ='{$ ID}';
$结果= $ DB->查询($查询);
如果($结果){
$数据['成功'] =真;
$数据['消息'] =更新成功!;
} 其他 {
$数据['错误'] =真;
}
回声json_en code($的数据);
}
?>
这是JSON响应:
<$p$p><$c$c>{"id":"360","months":"June","years":"1990","cottages":"Cedar","thoughts":"Hello","success":true,"message":"Update成功了!}
我同意上面的回答。我见过IE片与AJAX请求,GET和POST,当不使用一个缓存无效的字符串。只需添加一个随机的缓存清除字符串的URL像这样:
$。员额(?update.php TS =+新的日期()getMilliseconds(){缓存:假的,saveID:saveIt.value,saveMo:saveMonth,saveYr :saveYear,saveCtg:saveCt,saveThg:午餐节省},
功能(数据){
...
和它应该只是开始在IE工作。
I can't get this update script to work in IE. Works fine in every other browser. IE tells me that the update was performed. However, it wasn't. I've no more hair left to pull out..grr. BTW I've tried $.ajax
and $.get
too..still no luck. I'm thinking it may have something to do with the live
click handler. Don't know...I've tried everything..(putting headers for no-cache, attaching a random number to the end of my url string)..nothing fricken works...blasted IE.
This is the $('.save').live('click')
function I am using:
$(".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;
});
Here's the 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);
}
?>
This is the JSON response:
{"id":"360","months":"June","years":"1990","cottages":"Cedar","thoughts":"Hello","success":true,"message":"Update Successful!"}
I agree with the answer above. I've seen IE flake with AJAX requests, both GET and POST, when a cache-busting string is not used. Just append a random cache busting string to your URL like so:
$.post("update.php?ts="+new Date().getMilliseconds(), { cache : false, saveID : saveIt.value, saveMo : saveMonth, saveYr : saveYear, saveCtg : saveCt, saveThg : saveTh },
function(data){
...
and it should just start working in IE.
这篇关于jQuery的$。员额更新不工作在IE浏览器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!