How to post data / login to a web site via XMLHTTPRequest
Hi everybody, I need some help. I'd like login to www.mywebsite.com/login.html and keep the cookies in order to be used when I will submit the Travel Form as you need to login first before to submit the travel form.
Nothing is happening when I try to click on "Login" button.
Below is my code and the screenshot of the form.
- <!DOCTYPE html>
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<script>
$(document).ready(function(){
$("button").click(function(){
$.post("https://www.mywebsite.com/login.html",
{
login: "alice007@gmail.com",
password: "alice1995"
},
function(data,status){
alert("Data: " + data + "\nStatus: " + status);
});
});
});
</script>
</head>
<body>
<button>Send an HTTP POST request to a page and get the result back</button>
</body>
</html>