I have the following code:
function GET_URLAsync(strUrl, aParm) {
var response = $.ajax({
type: "POST",
url: "../Paginas/" + strUrl,
data: JSON.stringify(aParm),
contentType: "application/json; charset=utf-8",
dataType: 'json',
});
response.always(function (data) {
//replace to complete
});
response.done(function (data) {//replace to success
var registros = data.d;
if ($.type(registros) != "null") {
//dataReturn = registros;
return registros
} else {
console.log("Data NULL del servidor ");
return [];
}
});
response.then(function (data) {
//Incorporates the functionality of the .done() and .fail() methods
});
response.fail(function (data) { //replace to error
// handle request failures
swal("Error petición GET");
});
return response;
}
It is a standard function that makes calls to the server. the way I use it is as follows.
//Llamada al servidor de manera Asincrona. :D
GET_URLAsync(strUrl, aParm).done(function (periodos) {
console.log(periodos)
f_LlenarListaPeriodosAlumnos(periodos);
});
The problem is that doing console.log(periodos)
. I get an object, and to recover my list I have to put again the .d
( periodos.d
).
How could I make the .done
previous of the standard function return the clean list to me and no longer have to put .d
. Something like:
$.ajax({})
.done(function(){
return "hola "
})
.done(function(dataHola){
return dataHola+" Vitmar"
})
.done(function (dataHolaVitmar){
console.log(dataHolaVitmar)
});
Will it be possible? Thanks.