我试图通过post方法发送一个json,但它似乎没有正确发送,因为它跳过了代码错误函数,我不知道为什么。
这是我的表单代码:
<form name="login" action="" method="post">
<input type="text" id="email" placeholder="User">
<input type="password" id="pass" placeholder="Password">
<button type="submit" id="send" onclick="sendForm()">Enter</button>
<div class="moreoptions">
<div class="ico">
<span class="glyphicon glyphicon-lock" aria-hidden="true"></span>
<a href="#">I forgot my password</a>
</div>
<div class="ico">
<span class="glyphicon glyphicon-save" aria-hidden="true"></span>
<a href="#">Register</a>
</div>
</div>
</form>
这是我的js代码:
function sendForm(){
var fpU = ROT47(document.forms[0].elements[0].value);
var fpP = ROT47(document.forms[0].elements[1].value);
var objJSON = {
pdf: "login",
fpU: fpU,
fpP: fpP,
browserInfo: {
appCodeName: navigator.appCodeName,
appName: navigator.appName,
appVersion: navigator.appVersion,
cookieEnabled: navigator.cookieEnabled,
language: navigator.language,
platform: navigator.platform,
userAgent: navigator.userAgent
},
datasite: {
"@accountID": "2",
"@siteID": "3"
}
};
$.ajax({
url: 'https://www.evstest.com/G3v1LastVersion/portal/portal_action.php',
data: objJSON,
method: 'post',
async: false,
dataType: 'application/json',
success: function(response){
alert("done");
},
error: function(error){
alert("error");
}
});
}
我在本地工作,我必须通过post方法发送json的URL是外部的,只是我放在示例中的那个,我说它以防它与它有关,因为我的代码失败
始终最终离开警报消息。 有人知道我做错了吗?
问候和感谢!!!