I'm making an application which connects to the server and receives a series of data in json format, in the case that there is no available data returns a text, what I want to know is how to redirect the text to a variable and the data to another
I'm making an application which connects to the server and receives a series of data in json format, in the case that there is no available data returns a text, what I want to know is how to redirect the text to a variable and the data to another
Try this:
$.post('myurl.com/api/todo', {'parametros': {}}, function(data){
try {
var obj = JSON.parse("OK");
//login cuando es un json
}
catch(error) {
console.log('Es un texto');
//login cuando no hay datos
}
});