jquerycoldfusion

Successful getJSON call not returning


I have the following jQuery calling a method in a coldfusion component

$.getJSON("/blah/listing.cfc?method=bleep&returnformat=json",{"status":status},function(res,code)
   alert(res);
   if(res == 1){
      top.location.reload(true);
   }
   $('#chase-form .btnChase').removeAttr("disabled");
});
return true;

The call runs successfully and does what's it's supposed to. However, because of the way the component is written, it blocks the callback and the alert() does not fire. Until I sort out the reasons for the blocked callback, I need to get this page refreshing.

Is there some temporary bodge/hack I can use to just get the page to reload. I've tried a setTimeout function, but that doesn't work, e.g.

setTimeout(function(){
   $.getJSON("/blah/listing.cfc?method=bleep&returnformat=json",{"status":status},function(res,code){
      alert('here');
      $('#chase-form .btnChase').removeAttr("disabled");
      if(res == 1){
         top.location.reload(true);
      }
   }, 5000);
});

Solution

  • I found the problem. I started changing things around according to mykaf's suggestion and realized that I had a tag at the top of the included file. I don't know why but this caused the problem. I remove it and the original code worked fine. Thanks so much for the help.