Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/419.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
获取JSON之前的JavaScript登录_Javascript_Html_Ecmascript 6 - Fatal编程技术网

获取JSON之前的JavaScript登录

获取JSON之前的JavaScript登录,javascript,html,ecmascript-6,Javascript,Html,Ecmascript 6,我在/json <form action="/json" method="post"> <input class="form-control" type="password" name="password" id="ps" placeholder="Password" required> <input class="btn btn-outline-danger" type="su

我在
/json

            <form action="/json" method="post">
                <input class="form-control" type="password" name="password" id="ps" placeholder="Password" required>
                <input class="btn btn-outline-danger" type="submit" value="ENTER" id="ab">
            </form>
如何做到这一点

我可以在chrome控制台上用

document.getElementById('ps').value = 'test'
document.getElementById('ab').click()

您需要定义
onsubmit
值,如

        <form action="/json" method="post" onsubmit="document.getElementById('ps').value = 'test';">
            <input class="form-control" type="password" name="password" id="ps" placeholder="Password" required>
            <input class="btn btn-outline-danger" type="submit" value="ENTER" id="ab">
        </form>
并在
onsubmit
中调用:

        <form action="/json" method="post" onsubmit="beforeSubmit();">
            <input class="form-control" type="password" name="password" id="ps" placeholder="Password" required>
            <input class="btn btn-outline-danger" type="submit" value="ENTER" id="ab">
        </form>

您需要定义提交时的
值,如

        <form action="/json" method="post" onsubmit="document.getElementById('ps').value = 'test';">
            <input class="form-control" type="password" name="password" id="ps" placeholder="Password" required>
            <input class="btn btn-outline-danger" type="submit" value="ENTER" id="ab">
        </form>
并在
onsubmit
中调用:

        <form action="/json" method="post" onsubmit="beforeSubmit();">
            <input class="form-control" type="password" name="password" id="ps" placeholder="Password" required>
            <input class="btn btn-outline-danger" type="submit" value="ENTER" id="ab">
        </form>

只需使用密码发送
POST

fetch('/json', {
    method: 'POST',
    body: new URLSearchParams("password=test")
})
    .then(res => res.json())
    .then((out) => {
        document.getElementsByTagName('textarea')[0].innerHTML = out.Proxies.join("\n");
    })
    .catch(err => { throw err; });

只需使用密码发送
POST

fetch('/json', {
    method: 'POST',
    body: new URLSearchParams("password=test")
})
    .then(res => res.json())
    .then((out) => {
        document.getElementsByTagName('textarea')[0].innerHTML = out.Proxies.join("\n");
    })
    .catch(err => { throw err; });

如何绑定表单元素上的submit事件并将抓取作为回调传递给事件处理程序?如何绑定表单元素上的submit事件并将抓取作为回调传递给事件处理程序?