I'm having some issues using Jquery & Ajax to submit a form to my API that is powered by Flask-RestPlus & Python. When I run my API from CURL, or using swagger it works as predicted, however when I try to use Jquery/Ajax to submit a form to the same endpoint I am not getting any data from the form submission.
Here is the the HTML/Jquery
<form name="login" id="login">
<input type="text" name="email" id="email">
<input type="password" name="password" id="password">
<button type="submit">Submit</button>
</form>
</body>
<script>
$("#login").submit(function(e) {
var url = "/auth/login_user"; //
$.ajax({
type: "POST",
url: url,
data: $("#login").serializeArray(), // I've tried serializeArray() & serialize()
success: function(data)
{
alert(data);
}
});
e.preventDefault();
});
</script>
When I inspect the code inside the browser it looks like it is sending the form data, but when I print it in my console from my python function I can tell I am getting a None type.
Any help would be much appreciated. I know I can user Jquery.val() to get the value of each form element but it doesn't seem like the correct way to solve this issue.