首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >为什么这个JavaScript会冻结IE6?

为什么这个JavaScript会冻结IE6?
EN

Stack Overflow用户
提问于 2010-11-29 16:52:15
回答 1查看 343关注 0票数 0

当您单击此页面上的“添加到包”时,每次都会冻结IE6。我怎么才能弄明白为什么这么冷?有谁有更直接的答案吗?

总体曲目{dot} com {slash} Safety0.html

代码语言:javascript
运行
复制
function update() {
    $.ajax({
        dataType: 'json',
        type: 'POST',
        url: '/cgi-bin/ajax_cart_count.cgi',
        timeout: 2000,
        success: function (data) {
            // If bag is empty, it's see through.
            if (data.cart_count == 0) {
                $(".shopping_bag").css("opacity", ".2");
            }
            // If bag is not empty, it's not see through.
            else {
                $(".shopping_bag").css("opacity", "1");
            }
            $("#bag_total").html(data.grand_total);
            $("#bag_count").html(data.cart_count);
            window.setTimeout(update, 15000);
        },
        error: function (XMLHttpRequest, textStatus, errorThrown) {
            $("#bag_total").html('Timeout contacting server..');
            window.setTimeout(update, 60000);
        }
    })
}
$(document).ready(update);

代码语言:javascript
运行
复制
// preparethe form when the DOM is ready 
$(document).ready(function () {
    // bind form using ajaxForm 
    $('.add_to_cart_form').ajaxForm({
        beforeSubmit: loading,
        success: myBox
    });
});
// preparethe form when the DOM is ready
$(document).ready(function () {
    // bind form using ajaxForm
    $('.add_to_cart_form').ajaxForm({
        beforeSubmit: loading,
        success: myBox
    });
});
// $(".add_to_cart_form").click(function () {
// $('.bypass_add_to_cart_form').ajaxForm({ success: myBox });
// });

function loading() {
    $("#loadingContent").show();
}
function myBox(resptext, statustext) {
    $("#loadingContent").hide();
    Boxy.ask(resptext, ["View Bag", "Continue Shopping"], function (val) {
        if (val == "View Bag") {
            document.location.href = "/cgi-bin/store.cgi?action=view_cart";
        }
        if (val == "Continue Shopping" && product_detail == 1) {
            history.go(-1);
        }
    }, {
        title: "Add to Bag"
    });
    $('.bypass_add_to_cart_form').ajaxForm({
        beforeSubmit: loading,
        success: myBox
    });
    update();
    return false;
}
/*     
 This tells the ajax-style add to cart that      
 it's on a product detail page so if the      
 user clicks "Continue Shopping" it takes      
 them back on step in their history.     
 */
$('.search_view').click(function () {
    product_detail = 0;
});
$('.product_view').click(function () {
    product_detail = 1;
});
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2010-12-21 01:29:55

调试一个从外部立即冻结的东西是不容易的。但它总是一个好主意,清理整体,删除不重要的东西,检查功能,然后再做下一步。

例如:

代码语言:javascript
运行
复制
// preparethe form when the DOM is ready 
$(document).ready(function () {
    // bind form using ajaxForm 
    $('.add_to_cart_form').ajaxForm({
        beforeSubmit: loading,
        success: myBox
    });
});
// preparethe form when the DOM is ready
$(document).ready(function () {
    // bind form using ajaxForm
    $('.add_to_cart_form').ajaxForm({
        beforeSubmit: loading,
        success: myBox
    });
});

不难看出,这里有两次这个部分。

在你的应用程序中增加一点准确性,而不是复制和粘贴。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/4305971

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档