Note that there are some explanatory texts on larger screens.

plurals
  1. POajax call to servlet puzzler
    text
    copied!<p>Greetings!</p> <p>I'm having a problem getting a text value of a captcha from a servlet through ajax call. </p> <p>When my captcha gets created, its text value is written to session, but after refreshing the image itself though ajax call, I only get one old value of the text.</p> <p>Refreshing the image itself works ok, but I'm stuck getting the correct values from the session on subsequent call.</p> <p>On page reload I get both the new image and its new text value, no joy with ajax though.</p> <p>This works great for the image refresh:</p> <pre><code>$("#asos").attr("src", "/ImageServlet?="+((new Date()).getTime()) ) </code></pre> <p>This call to another method to get text value gives me old stuff:</p> <pre><code> $.ajax({ url:"checkCaptcha", type:"GET", cache: false, success: function( data) { alert(data); } }); </code></pre> <p>Any feedback will be appreciated.</p> <p>ps: here's the meat of the method getting the call:</p> <pre><code> PrintWriter out = response.getWriter(); response.setContentType("text/html"); response.setDateHeader("Expires", 0 ); // Set standard HTTP/1.1 no-cache headers. response.setHeader("Cache-Control", "no-store, no-cache, must-revalidate"); // Set IE extended HTTP/1.1 no-cache headers (use addHeader). response.addHeader("Cache-Control", "post-check=0, pre-check=0"); // Set standard HTTP/1.0 no-cache header. response.setHeader("Pragma", "no-cache"); out.print( request.getSession( ).getAttribute("randomPixValue") ); out.close(); </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload