// The error handling function ensures that event processes run normally in case of JS load or initialization errors.// Define the function before the script loadsfunction loadErrorCallback() {var appid = 'CaptchaAppId';// Generate a disaster recovery ticket or use another handling techniquevar ticket = 'trerror_1001_' + appid + '_' + Math.floor(new Date().getTime() / 1000);callback({ret: 0,randstr: '@'+ Math.random().toString(36).substr(2),ticket,errorCode: 1001,errorMessage: 'jsload_error',});}
try {// Generate a CAPTCHA objectvar captcha = new TencentCaptcha(document.getElementById('cap_iframe'), 'Your CAPTCHA's CaptchaAppId', callback, {});// Call the method to show the CAPTCHAcaptcha.show();} catch (error) {// Load error. Call the CAPTCHA js load error handling function.loadErrorCallback();}
function callback(res) {// res (CAPTCHA is closed by the user) = {ret: 2, ticket: null}// res (Verification is successful) = {ret: 0, ticket: "String", randstr: "String"}// res (Request error. A disaster recovery ticket with the prefix trerror_ is returned.) = {ret: 0, ticket: "String", randstr: "String", errorCode: Number, errorMessage: "String"}if (res.ticket){// Handle based on errorCodeif(res.errorCode === xxxxx){// Customize the disaster recovery logic (for example, skip this verification)}}}
{"Response": {"Error": {"Code": "InternalError","Message": "An internal error has occurred. Retry your request. If the problem persists, contact us."},"RequestId": "xxxxxxxxxxx"}}
{"Response": {"CaptchaCode": 26,"CaptchaMsg": "System busy. For more information, please see the Captcha documentation. Search for the keyword "DescribeCaptchaResult", and check the description of the CaptchaCode field in the output parameters","EvilLevel": 0,"GetCaptchaTime": 0,"RequestId": "xxxxxxxxxxx"},"retcode": 0,"retmsg": "ok"}
Feedback