weixin_33737774 2010-02-18 03:56 采纳率: 0%
浏览 29

Servlet拼图的Ajax调用

Greetings!

I'm having a problem getting a text value of a captcha from a servlet through ajax call.

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.

Refreshing the image itself works ok, but I'm stuck getting the correct values from the session on subsequent call.

On page reload I get both the new image and its new text value, no joy with ajax though.

This works great for the image refresh:

$("#asos").attr("src", "/ImageServlet?="+((new Date()).getTime()) )

This call to another method to get text value gives me old stuff:

        $.ajax({
        url:"checkCaptcha",
        type:"GET",
        cache: false,
        success: function( data) {
            alert(data);
        }
    });

Any feedback will be appreciated.

ps: here's the meat of the method getting the call:

        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();
  • 写回答

4条回答 默认 最新

  • weixin_33694620 2010-02-18 04:01
    关注

    Looks like you need to add a file extension to your url. Assuming it's an html page you're making the ajax call to:

    $.ajax({
        url:"checkCaptcha.html",
        type:"GET",
        cache: false,
        success: function( data) {
            alert(data);
        }
    });
    
    评论

报告相同问题?

悬赏问题

  • ¥15 怀疑手机被监控,请问怎么解决和防止
  • ¥15 Qt下使用tcp获取数据的详细操作
  • ¥15 idea右下角设置编码是灰色的
  • ¥15 全志H618ROM新增分区
  • ¥15 在grasshopper里DrawViewportWires更改预览后,禁用电池仍然显示
  • ¥15 NAO机器人的录音程序保存问题
  • ¥15 C#读写EXCEL文件,不同编译
  • ¥15 MapReduce结果输出到HBase,一直连接不上MySQL
  • ¥15 扩散模型sd.webui使用时报错“Nonetype”
  • ¥15 stm32流水灯+呼吸灯+外部中断按键