0

I have the following code:

<div id="results">loading image</div>
<script>
function load_url(url) 
{
    var obj;
    if (window.XMLHttpRequest) obj = new XMLHttpRequest();
    else if (window.ActiveXObject) obj = new ActiveXObject("Microsoft.XMLHTTP");

    if (obj !== null) 
    {
        obj.onreadystatechange = function() 
        {
            if (obj.readyState == 4 && obj.status == 200) 
            {
            var response = obj.responseText;
            alert(response);
            document.getElementById('results').innerHTML = response;
            }
        };

        obj.open("GET", url, true);
        obj.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
        obj.send();
    }
}

load_url('_mainpageResults.cfm?tStatus=<cfoutput>#tStatus#&tFinalSort=#tFinalSort#&tDirection=#tDirection#&tSection=#tSection#&tSort=#tSort#</cfoutput>');

</script>

The initial load, while long (I think that's a factor of the page inside and the queries taking long, but that's a different issue) loads correctly. However, short of me changing something so that one of the parameters is different, the page doesn't register code changes.

For example, if, via the pulldown on the page I change the "tStatus" from "Open" to "Closed" it'll realize there's new code in there and run it. However, if I go back and change it to "Open" again, it'll just load up the old version and not realize that I've added code.

Also, in a possibly related note, the rendered table that comes back is WAY out of proportion.

I originally called this page using a <cfdiv> but was advised against that by folks in here. This was working fine with the <cfdiv> but I'm trying to make it cleaner.

Thanks.

Reverend Bubbles
  • 1,363
  • 5
  • 15
  • 29
  • Have you tried clearing your ColdFusion cache in your CF Admin? – Cory Fail Feb 26 '14 at 21:31
  • 2
    If you do not want pages to be cached, you should [assign the proper headers](http://stackoverflow.com/questions/49547/making-sure-a-web-page-is-not-cached-across-all-browsers/2068407#2068407). Side note, you might want to think about using jQuery, instead of ActiveXObject, so you are not limited to IE only. – Leigh Feb 27 '14 at 01:26

2 Answers2

2

Doesn't IE cache Ajax returns by default?

In jQuery I have to do:

$.ajaxSetup( {cache: false} );
Josh
  • 21
  • 3
1

Try this old trick. Add a random string as a URL parameter to avoid page caching. You could use CreateUUID() function in your page load call like this:

load_url('_mainpageResults.cfm?tStatus=<cfoutput>#tStatus#&tFinalSort=#tFinalSort#&tDirection=#tDirection#&tSection=#tSection#&tSort=#tSort#&rstr=#CreateUUID()#</cfoutput>');

As for how your table looks you don't give us enough info to help you.

Mag
  • 101
  • 3
  • Thanks for the UUID thought. I'll try that out. As far as the table, I kind of figured as much, but I'm not really sure how to give enough information so I might be stuck figuring that one out on my own. I think it has to do with the fact that when I call it as an AJAX call, it's rendering as a whole new page, instead of a part of the original page. I have a few thoughts. Thanks again for the UUID tip! – Reverend Bubbles Feb 26 '14 at 22:15
  • I figured out what was going on with the table layout! I had debugging turned on and CF debugging, for the fun of it, throws in a bunch of closing tags. It was closing cells/rows/tables/etc in the middle of my table, throwing everything off! – Reverend Bubbles Feb 27 '14 at 21:27