-1
I want to pass values via ajax of a text field on my screen for my action, I am doing as follows:
$('#Regra').change(function () {
if ($(this).val().trim != '') {
var regra = $('#Regra').val();
var tipoAtribuicao = $('#TipoAtribuicao').val();
$.fiajax({
url: urlTipoAtribuicao,
type: 'POST',
contentType: "application/json; charset=utf-8",
data: { regra: regra, tipoAtribuicao: tipoAtribuicao },
success: function (data) {
if (data.status && data.status == 'OK') {
console.log('entrou');
$('#DescricaoRegra').val(data.record.Descricao);
} else {
console.log('entrou no else');
if (data.error && data.error.Message)
alert(data.error.Message);
}
}
});
}
});
I want to pass the Rule field and the Type field, however it is giving error 500, I am doing something wrong ?
What kind of element is
#TipoAtribuicao
? It’s an input, a select...? And why are you using itcontentType: "application/json; charset=utf-8"
? Error500
is server error. Where is this error? In Alert?– Sam