Quantcast
Channel: Adobe Community : Unanswered Discussions - ColdFusion
Viewing all articles
Browse latest Browse all 5794

Problem with jquery .load and cfinclude

$
0
0

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


Viewing all articles
Browse latest Browse all 5794

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>