This is a simple login form which is working fine with most of the users, but for some reason there are several users that get 400 (Bad Request) when try to login. There is nothing special with the usernames they use like - having special symbols, special words or etc.
I have already tried several times to change the data format or or use JSON.stringify() of the username and password, but at the end not only the problematic users could not login, but all others.
$('#submit').click(function() {
username = $('#username').val();
password = $('#password').val();
$.ajax({
type: 'POST',
url: '/auth/signin',
data: 'username=' + username + '&password=' + password,
success: function(json) {
location.reload(true);
},
error: function (xhr, ajaxOptions, thrownError) {
$('#login-error').html('Invalid username/password');
}
});
return false;
});
Even if I try to see the thrownError it only gives me "error"
jquery.js:4 POST http://website/auth/signin 400 (Bad Request)
send @ jquery.js:4
ajax @ jquery.js:4
(anonymous) @ login.js:39
dispatch @ jquery.js:3
r.handle @ jquery.js:3
Bad Request
error
jQuery v1.11.1
How can I see the POST executable, cause even in the netwrok tab of chrome inspect there is nothing registered? How is it possible to work with one data (user/pass - they are valid), but not with other , just with different char sequence?
Using encodeURIComponent for user/pass solved this problem
More info thanks to Andreas to:
Does ajax post data need to be URI encoded?