function DeleteRule(ruleId) {
var deleteRuleAction = $('#delete-rule-action').val();
$.post(deleteRuleAction, { ruleId: ruleId }, function(data) {
if (data.Status == 'Success') {
alert(data.Messages[0]);
$('#rule-details-' + ruleId).fadeOut(500);
$('#div-rule-button-' + ruleId).fadeOut(500);
activeRuleId = null;
}
else
alert(data.Messages[0]);
}, 'json');
}
2) Save-回调时保存需要刷新页面以显示新添加的元素和现有元素
function SaveRule() {
var ruleId = $('#rule-id').val();
var saveOrUpdateRuleAction = $('#add-or-edit-rule-action').val();
$.post(saveOrUpdateRuleAction, { ruleId: ruleId }, function(data) {
if (data.Status == 'Success') {
alert(data.Messages[0]);
location.reload(true);
// This is supposed to reload the page after saving the element.
// But the page gets reloaded without display the alert on the previous line.
}
else
alert(data.Messages[0]);
}, 'json');
}
我将此保存函数称为:
<button type="submit" onclick="javascript:Save()">
<button type="submit" onclick="javascript:Save(); return false;">
在使用FireBug时,Delete显示了一个成功的POST和JSON数据的返回。但是Save(没有hack)显示“中止”