开发者

Is it possible to download image using Ajax

开发者 https://www.devze.com 2022-12-25 02:23 出处:网络
I know we can request xml, html as well as text images directly using ajax but can we request files lik开发者_开发技巧e image, zip etc. using Ajax. How ?Ajax just means \"Making an HTTP request from J

I know we can request xml, html as well as text images directly using ajax but can we request files lik开发者_开发技巧e image, zip etc. using Ajax. How ?


Ajax just means "Making an HTTP request from JavaScript without leaving the page", so yes.

You can't do much that is useful with a zip file or an image if you fetch it with XMLHttpRequest though.

Images can be added to the document by simply generating a new <img> element.

It might help if you provided more information about what you were trying to achieve. It sounds like an xy problem.


You could transport the image over an xmlRequest as base64, but since base64 is ~30% larger it will have some impact on your speed.


Yes, you can do so. Actually the same ajax principles apply here too. You use a server-side language to download a file.

0

精彩评论

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