Javascript-how can I parse the obtained results after I use WeChat to scan the bar code?

Source: Internet
Author: User
How to parse the result obtained by {code?
Wx. scanQRCode ({needResult: 1, // The default value is 0. the scan result is processed. 1 directly returns the scan result. scanType: ["qrCode", "barCode"], // you can specify whether to scan the QR code or a QR code. by default, both of them have success: function (res) {var result = res. resultStr; // the result returned by scanning the code when the needResult is 1 }});

How to parse the result obtained?

Reply content:
Wx. scanQRCode ({needResult: 1, // The default value is 0. the scan result is processed. 1 directly returns the scan result. scanType: ["qrCode", "barCode"], // you can specify whether to scan the QR code or a QR code. by default, both of them have success: function (res) {var result = res. resultStr; // the result returned by scanning the code when the needResult is 1 }});

How to parse the result obtained?

Var result = res. resultStr; // the result returned by the scan code when the needResult is 1.

Use the debugger, console. log () to print the result value parsing

What does your question mean?
I don't understand. Is the result not the scan result.
You can use the string method to get what you want,
Or pass ajax to the background
Orwindow.location.href = resultAll page jumps are allowed.

First, yourresWhat is the data type? If yesjsonFormat.JSON.parseConvert to an object to continue the operation.

Success: function (res) {var result = JSON. parse (res); // Convert the json type res to the object if (result. needResult = 1) {alert ('Nice! ');}}

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.