开发者

load Same Picture Without cache

<div id="dialog">
    <img src="NewCapthch.jpg" id="imgcaptcha"/>
</div>

<input id="Submit1" onclick ="dial();" type="submit" value="submit" />

function dial(){
     开发者_JAVA技巧 jQuery.get("Captch.aspx?id=" + Math.random());//success run and get
      $("#imgcaptcha").attr("src", "NewCapthch.jpg?id="+Math.random());//dose not set new image
    $("#dialog").dialog()
};

what does not change image?

I think load From Cache.


Simple mistake, change "NewCapthch.jpg?id" to "NewCapthch.jpg?id="

function dial(){
      jQuery.get("Captch.aspx?id=" + Math.random());//success run and get
      $("#imgcaptcha").attr("src", "NewCapthch.jpg?id="+Math.random());//dose not set new image
    $("#dialog").dialog()
};


Guess you should wrap the 2nd and 3rd call insinde the callback function off jQuery.get

        function dial() {
        jQuery.get("Captch.aspx?id=" + Math.random(), function () {
            $("#imgcaptcha").attr("src", "NewCapthch.jpg?id" + Math.random());
            $("#dialog").dialog();
        });
    }   
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜