开发者

Loading images using jquery and Ajax

开发者 https://www.devze.com 2023-01-02 20:15 出处:网络
I have an image tag that fires a jquery function using ajax, when clicked, to download images from another source to the server.

I have an image tag that fires a jquery function using ajax, when clicked, to download images from another source to the server. At the same time when the image is clicked it opens up a new tab a开发者_StackOverflownd tries to load the image that is being downloaded. How can I make the link not open until the image is finished downloading to the server?

This is the html

<a target="_blank" href="link_to_full_image" \> <img src="link_to_thumbnail" border=0/></a>


Set the link's CSS display property initially to "none" and then after your Ajax response set display to block.


You can use window.open when the ajax-request has finished loading the image. And your onClick-event on the link should have a return false; to stop the html-link from doing what it's supposed to do (open the href in a blank page).

0

精彩评论

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