Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/ssis/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
AJAX编码中的变量代码_Ajax - Fatal编程技术网

AJAX编码中的变量代码

AJAX编码中的变量代码,ajax,Ajax,我在ajax教程中找到了一段代码,但不熟悉其中的某些代码 ajaxRequest.onreadystatechange = function(){ if(ajaxRequest.readyState == 4){ document.myForm.time.value = ajaxRequest.responseText; } } ajaxRequest.open("GET", "pay.php", true); aj

我在ajax教程中找到了一段代码,但不熟悉其中的某些代码

ajaxRequest.onreadystatechange = function(){
        if(ajaxRequest.readyState == 4){
            document.myForm.time.value = ajaxRequest.responseText;
        }
    }
    ajaxRequest.open("GET", "pay.php", true);
    ajaxRequest.send(null); 
有人能告诉我上面的代码是什么意思吗,有没有变量等?
我知道pay.php是它所引用的php文件,但前三行代码是什么意思?

XMLHttpRequest对象有一个名为readyState的属性。这是存储服务器响应状态的位置。响应可以是处理、下载或完成。每次readyState更改时,都会执行onreadystatechange函数

当属性readyState为4时,表示响应已完成,您可以获取数据


该函数引用名为time的文本框,在名为myform的表单中,“该值取自pay.php文件中的代码。

因此,如果我想将其填充到名为form的表单中的文本框time中,则代码应为document.form.date.value=ajaxRequest.responseText;