翻译接口响应捕获处理
对 translate.js 请求后端接口的响应进行捕获。使用方式为:
//自定义响应的拦截捕获translate.request.response = function(xhr){ //xhr : XMLHttpRequest 接口请求 console.log('response:'); console.log(xhr);}
注意事项
- 此代码要放在
translate.execute(); 前面 - 无论后端翻译接口响应是否成功,都会触发此处。
- 另外当 xhr.readyState==4 的状态时才会触发。
- 此处会在接口请求响应后、且在 translate.js 处理前就会触发
支持版本
需要 translate.js v20231108 及以上版本
对 translate.js 请求后端接口的响应进行捕获。使用方式为:
````
//自定义响应的拦截捕获
translate.request.response = function(xhr){
//xhr : XMLHttpRequest 接口请求
console.log('response:');
console.log(xhr);
}
````
## 注意事项
* 此代码要放在 ````translate.execute();```` 前面
* 无论后端翻译接口响应是否成功,都会触发此处。
* 另外当 xhr.readyState==4 的状态时才会触发。
* 此处会在接口请求响应后、且在 translate.js 处理前就会触发
## 支持版本
需要 [translate.js v20231108 及以上版本](549734.html)