开发者

IE7 jquery text update issue

开发者 https://www.devze.com 2023-03-04 13:43 出处:网络
I am having a shopping cart text update issue on an ASP.NET MVC2 ecommerce site. When a user wants to add an item, a user control pop-up allows them to choose certain options and then click on \"add t

I am having a shopping cart text update issue on an ASP.NET MVC2 ecommerce site. When a user wants to add an item, a user control pop-up allows them to choose certain options and then click on "add to cart".

  $(document).ready(function () {
        $('#sizeselectform :radio:first').attr('checked', 'checked');

        $('#sizeselectform').ajaxForm(function () {
            $('#sizeselectform').parents('div.popup').children('a.close').click();
            UpdateCartCount();
        });

    });

The UpdateCartCount function just updates the count of items in a shopping cart:

function UpdateCartCount() {
    $.ajax({
        type: "GET",
        url: "/ShoppingCart/GetCartItemsCount/",
        success: function (result, status, xmlHttpRequest) {            
            $('#cartItemCount').text(result);
        },
        error: function (xmlHttpRequest, status, e) {
            var errorMessage = 'Login: ' + xmlHttpRequest.status + ' - ' + xmlHttpRequest.statusText;
            $('#loginErrorMessage').html(errorMessage).show();
        },
        complete: function (xmlHttpRequest, status) {

        }
    });    
}

Everything works fine in Chro开发者_JS百科me, Firefox,etc except IE7. I suspect that the cart count is not updated in IE7 because the parent div is closed before called the UpdateCartCount() function but at this point I am not sure. Any suggestions?

Thanks,

EDIT:

I changed the call to POST, added a cache: 'false', content-type: 'application/text', and finally a random number to the URL to prevent caching (all suggested solutions to this IE issue)...and the ajax calls finally started working in IE.


If the div#cartItemCount won't be removed in this process, there shouldn't be any problems Did you check if the ajax call is triggered in IE7? You could use IE8 in IE7 mode for easier debugging or put some alerts() in the code to check if UpdateCartCount() with $ajax gets really called


I would suggest to check the value of result in your success callback. Maybe you have to specify the dataType: 'text' for your ajax request. I assume it is text, not HTML or Json.


I changed the call to POST, added a cache: 'false', content-type: 'application/text', and finally a random number to the URL to prevent caching (all suggested solutions to this IE issue)...and the ajax calls finally started working in IE.

0

精彩评论

暂无评论...
验证码 换一张
取 消