[英]How can I capture the Array object returned by an api call through HTTP GET?
The API call API调用
https://myhost.net/api/get_global_search_result/methods/test returns an Array object. https://myhost.net/api/get_global_search_result/methods/test返回一个Array对象。 I am trying to hold it in an Array object in order to read the attributes and values in it.
我试图将其保存在Array对象中,以便读取其中的属性和值。
var queryResult = [];
queryResult = browser.get('https://myhost.net/api/get_global_search_result/methods/test/');
console.log('result length: ' + queryResult.length);
This is what I see on my console: 这是我在控制台上看到的:
result length: undefined
If I load the above specified URL directly in a browser instance, it shows the Array with its contents. 如果我直接在浏览器实例中加载上述指定的URL,它将显示Array及其内容。
What is the better way of capturing the array object returned by this call? 捕获此调用返回的数组对象的更好方法是什么?
What about using JQuery ajax request. 如何使用JQuery ajax请求。 it would be some thing like :
就像这样:
$(document).ready(function() { $("#testbutton").click(function() { $.ajax({ url: 'http://localhost:9200/xyz/xyz/xfSJlRT7RtWwdQDPwkIMWg', dataType: 'json', success: function(data) { alert(JSON.stringify(data)); }, error: function() { alert('error'); } }); }); });
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.