Como passar parâmetros no $ ajax POST?
Eu segui o tutorial como indicado emisto ligação. No código abaixo, por algum motivo, os dados não são anexados ao URL como parâmetros, mas se eu os definir diretamente no URL usando/?field1="hello"
funciona.
$.ajax({
url: 'superman',
type: 'POST',
data: { field1: "hello", field2 : "hello2"} ,
contentType: 'application/json; charset=utf-8',
success: function (response) {
alert(response.status);
},
error: function () {
alert("error");
}
});