function girisAjaxKontrol() {
var kullanici = { 'kullaniciAdi': $('#username').val(), 'sifre': $('#password').val() };
$.ajax({
url: '/Giris/GirisGecerliMi',
type: 'POST',
data: kullanici,
success: girisAjaxReturn,
error: function (error) {
alert(error.toString());
}
});
}
Everything works fine when debugging the asp .Net MVC4 project. But, after publish, the code block above returns an alert message as “[object Object]”. Why error message is not string, and why it doesn’t work after publish?
The .error() event of jQuery.ajax() accepts three arguments:
Your .error() event is accepting one argument which automatically read by jQuery as the jQXHR object. To see it inside the alert, try to do something like this:
Or, you might want to return the description of the error:
The exception object is only returned if an HTTP error occured.