如何将 404 错误 XMLHttpRequest 修复到本地主机
How to fix 404 error XMLHttpRequest to a localhost
我在尝试发送 post 请求时在控制台上收到 404 错误。
我将 https://cors-anywhere.herokuapp.com/ 用作代理,因此我可以在我的本地主机上解决所有跨域问题。
我的代码是:
function test() {
var xhttp = new XMLHttpRequest();
xhttp.onreadystatechange = function () {
alert(this.readyState + " // " + this.status);
}
xhttp.open("POST", "https://cors-anywhere.herokuapp.com/http://localhost/safecom/webuser.dll/Welcome", true);
xhttp.send("flogon=test&fpwd=123456");
}
localhost页面形式为:
<form method="post" enctype="application/x-www-form-urlencoded" name="loginForm" id="loginForm" action="Welcome">
<input type="hidden" name="redirpage" value="">
<input type="hidden" name="redirparam" id="redirparam" value="">
<input type="hidden" name="flogontext" value="User logon">
<input type="hidden" name="fpwdtext" value="PIN code">
<input type="hidden" name="flogonEnc" id="flogonEnc" value="">
<div class="login_form_element">
<div class="login_field_user_box_border">
<div class="login_field_user_box">
<div class="logon_field_lbl" id="lblUserLogon" onclick="field_focus(flogon)">User logon</div>
<input class="login_field_input" type="text" name="flogon" id="flogon" maxlength="254" size="24" value="">
</div>
</div>
</div>
<div class="login_form_element">
<div class="login_field_user_box_border">
<div class="logon_field_lbl_pwd" id="lblPassword" onclick="field_focus(fpwd)">PIN code</div>
<input class="login_field_password_input" type="password" name="fpwd" id="fpwd" maxlength="4" value="">
</div>
</div>
<div class="login_form_element">
<input id="btnloginsubmit" class="rounded_login_btn" type="submit" value="Login"></div>
Chrome 控制台将错误指向我发送 () 的行,说:
无法加载资源:服务器响应状态为 404(未找到)
问题是...当我使用网站的在线版本时它可以正常工作...但我想指向我的本地主机,因此我不需要在在线版本上进行更改。
http://localhost
是“我的电脑”的表示法。
所以当你将这个URL发送给https://cors-anywhere.herokuapp.com
进行处理时,系统会尝试访问https://cors-anywhere.herokuapp.com/something
,因为localhost
指向它的服务器,那个资源可以找不到。
不要使用代理或发送 your real IP address 而不是 localhost
来解决这个问题!
我在尝试发送 post 请求时在控制台上收到 404 错误。
我将 https://cors-anywhere.herokuapp.com/ 用作代理,因此我可以在我的本地主机上解决所有跨域问题。
我的代码是:
function test() {
var xhttp = new XMLHttpRequest();
xhttp.onreadystatechange = function () {
alert(this.readyState + " // " + this.status);
}
xhttp.open("POST", "https://cors-anywhere.herokuapp.com/http://localhost/safecom/webuser.dll/Welcome", true);
xhttp.send("flogon=test&fpwd=123456");
}
localhost页面形式为:
<form method="post" enctype="application/x-www-form-urlencoded" name="loginForm" id="loginForm" action="Welcome">
<input type="hidden" name="redirpage" value="">
<input type="hidden" name="redirparam" id="redirparam" value="">
<input type="hidden" name="flogontext" value="User logon">
<input type="hidden" name="fpwdtext" value="PIN code">
<input type="hidden" name="flogonEnc" id="flogonEnc" value="">
<div class="login_form_element">
<div class="login_field_user_box_border">
<div class="login_field_user_box">
<div class="logon_field_lbl" id="lblUserLogon" onclick="field_focus(flogon)">User logon</div>
<input class="login_field_input" type="text" name="flogon" id="flogon" maxlength="254" size="24" value="">
</div>
</div>
</div>
<div class="login_form_element">
<div class="login_field_user_box_border">
<div class="logon_field_lbl_pwd" id="lblPassword" onclick="field_focus(fpwd)">PIN code</div>
<input class="login_field_password_input" type="password" name="fpwd" id="fpwd" maxlength="4" value="">
</div>
</div>
<div class="login_form_element">
<input id="btnloginsubmit" class="rounded_login_btn" type="submit" value="Login"></div>
Chrome 控制台将错误指向我发送 () 的行,说: 无法加载资源:服务器响应状态为 404(未找到)
问题是...当我使用网站的在线版本时它可以正常工作...但我想指向我的本地主机,因此我不需要在在线版本上进行更改。
http://localhost
是“我的电脑”的表示法。
所以当你将这个URL发送给https://cors-anywhere.herokuapp.com
进行处理时,系统会尝试访问https://cors-anywhere.herokuapp.com/something
,因为localhost
指向它的服务器,那个资源可以找不到。
不要使用代理或发送 your real IP address 而不是 localhost
来解决这个问题!