Search code examples
javascriptjqueryprototypebusiness-catalyst

Business catalyst prototype-core.ashx Refused to set unsafe header "Connection" conflicts


I currently use Adobe Business Catalyst on an ecommerce site and it run into the same problem:

When clicking add to cart the log shows:

prototype-core.ashx Refused to set unsafe header "Connection"

all custom javascript I have and jQuery breaks and does not ready some functions.

I tried using methos such as jQuery noConflicts();

var j = jQuery.noConflict();

Still nothing works well, I cant provide a sample code because everything is working from the server and I use another method to have a work around it for the time being.

Any suggestions please advise.


Solution

  • If you have a look into the prototype-core.ashx you will find this

    if(!MS.Browser.isIE) {
            this.xmlHttp.setRequestHeader("Connection", "close") // Mozilla Bug #246651
        }
    

    This is not an issue, it is just a line of code your browser does not understand, if you use Mozilla you will not see this error in your console, but you will see a bunch of different warnings.

    There is quite a lot on Stackoverflow about the issue that JavaScript doesn't work after an Ajax call. What you can do to fix it is call all your functions again after the add to cart button has been pressed.

    So first I have my JavaScript functions FirstFunction(); SecondFunction(); ThirdFunction(); and then I call them like this

    function FirstFunction() {
        //do whatever you want to do
    }
    function SecondFunction() {
        //do whatever you want to do
    }
    function ThirdFunction() {
        //do whatever you want to do
    }
    $(document).ready(function () {
        // do it once onload
        FirstFunction();
        SecondFunction();
        ThirdFunction();
        $('.main_content').on('click',function() {
            // do it again onclick
            FirstFunction();
            SecondFunction();
            ThirdFunction();
        });
    });
    

    This way all your functions are loaded again when you click on inside .main_content.