How can I use callback function from ajax in another function
I've got function with ajax:
function correct_date(raw_date){
return $.ajax({
method: "GET",
url: "../date/correct.php",
data: {
method: 'correct_date',
date: raw_date
},
cache: false,
dataType: 'json',
success: function(result) {
console.log(result.DATE_NEW);
showTheValue(result);
}
});
}
var showTheValue = function(correct_day_value) {
console.log(new Date(correct_day_value.DATE_NEW).toLocaleDateString('de-DE'));
return correct_day_value;
};
And I want to have the response/data value from ajax in another function like that:
function correct_start_date() {
document.getElementsByTagName("INPUT")[1].value = showTheValue();
}
How can I use response data from ajax in another function ?
var showTheValue = function ...before the ajax, or make it an named functionfunction showTheValue() {}.function showTheValue(correct_day_value) {document.getElementsByTagName("INPUT")[1].value = showTheValue();}And i've got this error in console:index.html:87 Uncaught RangeError: Maximum call stack size exceededcorrect_dateandcorrect_start_datefunctions?