ajax - 当 ajax 调用失败时,如何阻止 Bootstrap x-editable 更新已编辑字段?

标签 ajax jquery twitter-bootstrap x-editable

当 ajax 调用失败时,如何阻止 Bootstrap x-editable 更新编辑字段?

我正在传递一个函数作为 url。

$('.order-price').editable({
    type: "text",
    title: "Order Price",
    url: function (params) {
        var orderID = $(this).data("order-id");
        var data = "OrderID=" + orderID + "&Price=" + params.value;

        $.ajax({
            type: 'post',
            url: '/Trades/SetOrderPrice',
            data: data,
            async: false,
            error: function (xhr, ajaxOptions, thrownError) {
                return false;
                // Do I return something here instead of false?

            }

        })
    }
});

最佳答案

您有两个选择,要么在回调中抛出异常,x-editable 将捕获它本身,要么您可以使用“成功”事件并在成功函数中返回一个空字符串,然后您就完成了

关于ajax - 当 ajax 调用失败时,如何阻止 Bootstrap x-editable 更新已编辑字段?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16744965/

相关文章:

php - 使用 AJAX 加载 PHP 页面是好习惯吗?

jquery - 关于 Canvas 调整大小的 HTML/Jquery 问题 - $(window).resize 与 $(window).load/$(document).ready

javascript - 由 javascript 驱动的 Bootstrap 选项卡中的 CKEditor

javascript - 离开站点而不是页面时 jquery 卸载

javascript - Bootstrap 模式未打开 - 通过脚本加载

javascript - Codeigniter ajax 调用无法正常工作

jquery - 如何在ListBox中加载大量数据? ASP.NET MVC 应用程序

javascript - FOSJsRouting 包返回错误 未找到“GET”的路由

jQuery//在向下箭头事件上上下移动

javascript - 创建桌面快捷方式