Home > Article > Web Front-end > jquery controls the display of image streams generated by the server_jquery
First, use the jquery controls the display of jquery controls the display of image streams generated by the server_jquery streams generated by the server_jquery path as a parameter, and ajax asynchronously transmits it to the background method to upload to the server. It is not possible to directly use Jquery to transmit it. It has no power to deal with the server. I won’t talk nonsense about the specific content. Just read the following, which is introduced in detail.
First, let me show you the renderings:
First, the first page is the initial page, and the second page is the QR code generated by the server after clicking submit. The jquery controls the display of jquery controls the display of image streams generated by the server_jquery streams generated by the server_jquery is directly converted into a string and returned to the page without saving the jquery controls the display of jquery controls the display of image streams generated by the server_jquery streams generated by the server_jquery.
Introduction:
First of all, this method of generating QR codes without saving can be implemented using scripts on the front end, which is what I did in the project.
Then js seems to be unable to accept the file stream from the server for operation, for security reasons. If this way is possible, please tell me, thank you.
Since the file stream cannot be obtained, then obtain the string. The tag has a special usage. In src, it is written like this: data:jquery controls the display of jquery controls the display of image streams generated by the server_jquery streams generated by the server_jquery/png;base64, iVBORw0KGgoAAAANSUhEUgAAAAEAAAAkCAYAAABId………………. The following one The long string is the string of the picture, and then there is the code. It is very easy to write.
Server:
public ActionResult GetFileASCII(string content) { System.IO.MemoryStream ms=new System.IO.MemoryStream(); //这一步是获取二维码 QRCodeHelper.GetQRCode(content, ms); return Content(Convert.ToBase64String(ms.GetBuffer())); }
Client:
$.get('url/*服务端地址*/', { content: 'http://blog.sina.com.cn/s/blog_50042fab0100mcuy.html/*要生成二维码的内容*/' }, function (data) { $('#testimg').attr('src', 'data:jquery controls the display of jquery controls the display of image streams generated by the server_jquery streams generated by the server_jquery/png;base64,' + data); });
Summary:
The code is very simple, not just a QR code, but you can do this without saving jquery controls the display of jquery controls the display of image streams generated by the server_jquery streams generated by the server_jquerys, like 'data:jquery controls the display of jquery controls the display of image streams generated by the server_jquery streams generated by the server_jquery/png;base64, which can also be generated on the server side.
The above is the entire content of this article, I hope it will be helpful to everyone.