0
I am making a JSON request, which returns the results, but not on the date, but on the ajax error.
var url = window.location;
var id = url.toString().split("=")[1];
var msg = '';
$.ajax({
type: 'POST',
url: 'load-data.php?id='+id,
dataType: 'json',
success: function(data) {
msg = data;
alert(msg)
},
error:function(e){
console.log(e)
}
});
I just don’t understand why the result appears in the ajax error.
You need to look at the console and know what the status is being returned.
– Wallace Maxters
200, if it is pag status, that is a ok
– Gabriel falieri
Check if the type of data ajax is like this;
dataType: "json"
– Leonardo Coelho
Yes, you are Leonardo
– Gabriel falieri
Why does it say that the result is in error? I see in
responseText
!– LS_ᴅᴇᴠ
Have you tried using other types to see if it has any different effect? You can use
text json
or justtext
– Leonardo Coelho
In the text, speaking truth, it worked
– Gabriel falieri
And in text json, same thing as the error
– Gabriel falieri
How is the return of your PHP ?
– Diego Souza
Do an echo json_encode in a select function
– Gabriel falieri
I’ll leave dataType : "text" even, it worked
– Gabriel falieri