0 Replies Latest reply on Mar 21, 2014 9:43 AM by TlalocW2

    Problem with jquery .load and cfinclude

    TlalocW2

      Another programmer has created a captcha file that's in a global directory so all we have do is call it with a CFINCLUDE, however, he did not build any kind of refresh into it.  So I created a work-around thusly:

       

      <div id="captchaDiv"><CFINCLUDE template="/cfincludes/captcha.cfm"></div>

      <a id="refreshCaptcha"  href="">refresh</a>

       

      Clicking the refresh link activates the following code:

       

      $(document).ready(function() {

          $.ajaxSetup ({

              // Disable caching of AJAX responses

              cache: false

          });

       

       

          $("#refreshCaptcha").click(function(e) {

             $("#captchaDiv").load("/ajax/captchaInclude.cfm?_="+Math.round(Math.random()*10000));           

             e.preventDefault();

           });

      });

       

      Since I can't reload a CFINCLUDE directly in an ajax call, I call /ajax/capthcaInclude.cfm, a local file in the website directory, that repeats the original cfinclude code that calls the global captcha

       

      <CFINCLUDE template="/cfincludes/captcha.cfm">

       

      On loading the page the first time, the captcha will work fine if you put in the right code.  However, if you can't read it and have to reload it, it will not work.  In playing with it, I also loaded my local /ajax/captchaInclude.cfm file via jQuery and got rid of the CFINCLUDE, and when I did that, it wouldn't work the first time either.

       

      Any ideas on what the problem is?  Thanks for your help