The difference between json object and json string while post with ajax:
var login = function(){
var user = $("input[name=username]").val();
var password = $("input[name=password]").val();
var data = {
username:user,
password:password
};
data = JSON.stringify(data);
console.log(data);
$.post(url_login, data, function(ele, status){
console.log(ele);
console.log(status);
});
}
Attention the command:
"data = JSON.stringify(data)"
It will post the data as normal request values if you didn't change data into a string in the function post. Otherwise as input stream.