Jquery controls the image stream generated by the Display Server _ jquery

Source: Internet
Author: User
This article mainly introduces how jquery controls the image stream generated by the display server. If you need it, you can refer to the following: Use the image path as a parameter, and upload ajax to the upload server in the background method asynchronously, it cannot be directly transmitted using Jquery. It does not have the right to deal with the server. The specific content is no longer nonsense. Let's take a look at the following and introduce it in detail.

First, we will show you:

<

The first is the initial page, and the second is the QR code generated by the server after clicking submit. If no image is saved, the image is directly transferred to a string and returned to the page.

Introduction:
First of all, this method of generating a QR code can be implemented by using a script on the front end without saving it. That is what I did in the project.

Then js seems to be unable to accept the file stream on the server for operation, for security reasons. If this method works, please let me know. Thank you.

Since the file stream cannot be obtained, the string is obtained and the tag has a special usage. In src, data is written as follows: image/png; base64, ivborw0kggoaaaansuheugaaeaaaakcayaaabid ................ A long string is the image string followed by the code, which is easy to write.


Server:

Public ActionResult GetFileASCII (string content) {System. IO. memoryStream MS = new System. IO. memoryStream (); // this step is to obtain the QR code QRCodeHelper. getQRCode (content, MS); return Content (Convert. toBase64String (ms. getBuffer ()));}


Client:

$. Get ('url/* server address */', {content: 'http: // response}, function (data) {$ (' # testimg '). attr ('src', 'Data: image/png; base64, '+ data );});

Summary:
The code is very simple. It is not only a QR code, but it can be done without saving images, such as 'data: image/png; base64, which can also be generated on the server.

The above content is all the content of this article and I hope it will help you.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.