Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Problem with jquery .load and cfinclude

Guest
Mar 21, 2014 Mar 21, 2014

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

691
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
no replies

Have something to add?

Join the conversation
Resources