从 http 适配器过程读取响应
Reading response from http adapter procedure
我有一个来自网络服务器的响应:
{
"errors": [ ],
"info": [ ],
"isSuccessful": true,
"responseHeaders":
{
"Connection": "close",
"Content-Length": "159",
"Content-Type": "text'/html",
"Date": "Sat, 20 Feb 2016 11:15:35 GMT",
"Server": "Apache",
"X-Powered-By": "PHP'/5.2.17" },
"responseTime": 705,
"statusCode": 200,
"statusReason": "OK",
"text": "True 'n<!-- Hosting24 Analytics Code -->'n<script type='"text'/javascript'" src='"http:'/'/stats.hosting24.com'/count.php'"><'/script>'n<!-- End Of Analytics Code -->",
"totalTime": 706,
"warnings": [ ]
}
我检索真实值的代码段:
var response = WL.Server.invokeHttp(input);
// Extract value from the response.
var type = typeof response;
if ("object" == type) {
if (true == response["isSuccessful"]) {
// Drill down into the response object.
var results = response["results"];
var result = results[0];
var val = result["text"];
// Return JSON object
return val;
}
else {
// Returning null. Web request was not successful.
return null;
}
}
如何向下钻取并仅从适配器 impl 中的"text": "True"
中提取值.js??
请问我能不能吃点。谢谢。
你能
试试这种方式吗?还有一件事,看你想返回json object
.so,必须是写json格式或转换json。
var response= WL.Server.invokeHttp(input);
if (response.statusCode==200 && response.isSuccessful==true){
var val =response.text
return {
data:val
}
}
else{
return null
}
相关文章:
- 如何从java中的URL读取JavaScript响应
- 未捕获的类型错误:无法读取 null 的属性“removeChild”(使用 Instagram 的 JSONP 响应)
- 在 Angular2 和 ionic 中读取 API 响应
- Angular无法读取http post响应中的cookie
- 正在读取angularjs中的HTTP服务器标头响应消息
- 如何读取在节点中发出的简单http请求的响应
- Json使用selfhost c#输出,并使用javascript读取响应
- Ajax在发送响应时从服务器读取响应
- dojo/request/iframe中读取xml响应的缺陷
- Java脚本将URL的响应读取到变量中
- 读取已解析的 JSON 响应
- 如何使用 ajax 或 jquery 读取异步 HTTP (servlet3.0) 响应
- 从 PHP 读取 json 响应并推送到 javascript 多维数组中
- 从 http 适配器过程读取响应
- 为什么在未读取响应的情况下,节点http客户端仍在运行
- 在Ajax php和mysql中读取响应
- 从JavaScript's fetch中重新读取响应体
- 使用JQuery在Ajax中读取响应文本
- 在ajax请求完成之前,以块的形式读取响应
- 使用 iron-ajax,如何读取响应的标头