[英]Understanding of ajax complete call
I'm struggling with stabilizing Selenium automation for jQuery/AJAX application hence referred to我正在努力稳定 jQuery/AJAX 应用程序的 Selenium 自动化,因此被称为
https://www.swtestacademy.com/selenium-wait-javascript-angular-ajax/ https://www.swtestacademy.com/selenium-wait-javascript-angular-ajax/
and it has ajaxComplete()
method which has following code -它有
ajaxComplete()
方法,其中包含以下代码 -
var callback = arguments[arguments.length - 1];
var xhr = new XMLHttpRequest();
xhr.open('GET', '/Ajax_call', true);
xhr.onreadystatechange = function() {
if (xhr.readyState == 4) {
callback(xhr.responseText);
}
};
xhr.send();
);
I haven't work on JavaScript before and this code which I'm not able to understand completely.我之前没有研究过 JavaScript,这段代码我无法完全理解。 I've following questions with this, if someone can help to understand it -
我有以下问题,如果有人可以帮助理解它 -
What is Ajax_call
in this?这
Ajax_call
是什么? Is it generic call to check ajax completion?是检查ajax完成的通用调用吗? Or do I need to have my own endpoint there?
还是我需要在那里有自己的端点? If yes, does single end point enough or do I need to identify all calls and add them in the method?
如果是,单个端点是否足够,或者我是否需要识别所有调用并将它们添加到方法中?
Please check the documentation for XMLHttpRequest.open .请检查XMLHttpRequest.open的文档。 If you do, you will the second argument listed is
如果你这样做,你将列出的第二个参数是
url
A DOMString representing the URL to send the request to.
一个DOMString表示要将请求发送到的 URL。
This means that it is simply the URL you want to request.这意味着它只是您要请求的 URL。 I can be anything you want.
我可以是你想要的任何东西。 The
/
prefix means that you are request relative to the root of the website (so if you are requesting from https://example.com/somedir/somepage
the request will be made to https://example.com/Ajax_call
. /
前缀意味着您是相对于网站根目录的请求(因此,如果您从https://example.com/somedir/somepage
请求,则请求将发送到https://example.com/Ajax_call
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.