I want to convert curl command :
curl -X POST -H "X-Requested-With: XMLHttpRequest" -H "Content-Type: application/json" -H "Cache-Control: no-cache" -d '{"username": "admin","password": "admin"}' "http://localhost:8080/api/auth/login"
to ajax jquery, i have tried to use this code below but it does not work:
$.ajax({
type: 'POST',
crossDomain: true,
url: 'http://localhost:8080/api/auth/login',
dataType : 'json',
data: JSON.stringify(datax),
success:function(data){
console.log(data);
},
error: function(data) { // if error occured
var responseText = $.parseJSON(data.responseText);
if(responseText.error){
}
}
})
.done(function(data) {
})