I have ajax call function which have parameter function and it's looks like this
function selectedLang(func) {
let selected = selectLang.options[selectLang.selectedIndex].value;
$.ajax({
url: 'lang.php',
type: "POST",
dataType: 'json',
data: { language: selected },
success: function (data) {
// call here displayData function with parameter
func(data);
}
});
}
inside success
i want to call function displayData
with parameter data
function displayData(data) {
// some data
}
selectedLang(displayData);
Right now i'm getting an error that func
is not a function
selectedLang(func){ let callback = func; [...] success: callback