I am trying to send a json by the post method, but it seems that it is not sent correctly, because it skips the code error function and I do not know why.
This is my form code:
<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>
this is my js code:
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");
}
});
}
I am working locally, and the URL that I have to send the json by the post method is external, just the one I put in the example, I say it in case it has something to do with it because my code fails.
Always ends up leaving the alert message. Anyone know I'm doing wrong?
Greetings and thanks!!!