P.Brian.Mackey
P.Brian.Mackey

Reputation: 44295

javascript - strange debugging issue

My code changes are not being reflected in IE or FF.

In IE: I commented out the alert('start'), but I still see the alert when I stop-restart my visual studio debugger.
In FF: Same code change, but none of the alerts show at all. I uncommented alert('start') and I still dont see it in FF.

I tried setting my port to stay fixed at 5204. I also stopped the ASP.NET development server prior to starting the debugger again. Still doesnt help.

Environment: VS 2010 IE7 and FF3.6.

Code

simplexhr = {
    doxhr: function (container, url) {
        //alert("START");
        if (!document.getElementById || !document.createTextNode) {
            alert("NO JS SUPPORT");
            return;
        }
        simplexhr.outputContainer = document.getElementById(container);
        if (!simplexhr.outputContainer) {
            alert("NO OUTPUT CONTAINER");
            return;
        }
        var request;
        try {
            //alert("Mozilla AJAX");
            request = new XMLHttpRequest();
            alert(request);
        }
        catch (error) {
            try {
                //alert("IE AJAX");
                request = new ActiveXObject("Microsoft.XMLHTTP");
            }
            catch (error) {
                return true;
            }
        }
        request.onreadystatechange = function () {
            if (request.readyState == 1)
                simplexhr.outputContainer.innerHTML = 'loading...';
        }
        alert("made it to try AJAX");
        request.open('get', url);
        //alert("ready state: " + request.readyState);
    }
}

UPDATE
On further testing, this problem is due to caching. But, it only happens when I use "unobtrusive javascript" or javascript inside its own *.js file linked in the header:

<script src="Scripts/simpleXHR.js" type="text/javascript"></script>

Moving the code into the page - viewing source - the javascript updates everytime with no caching issues. So is there a better way to perform "unobtrusive javascript"? Or should it be renamed "unproductive javascript" :P

Upvotes: 0

Views: 109

Answers (1)

Herms
Herms

Reputation: 38868

Sounds like it might be a browser cache issue. Try clearing your cache in each browser. Hopefully that will pick up the changes.

You could verify that by doing a view-source in the browser and see if you're actually getting the latest code.

Upvotes: 1

Related Questions