Answer the question
In order to leave comments, you need to log in
Why is the numeric variable received via Ajax not printed?
function getAjaxResult(url,data=null){
var res;
$.get(
url,
{data:data},
function (result) {
res=result;
},
"json"
);
return res;
}
$('.btn').click(function(){
alert(getAjaxResult('/get_products_select_count',null));
});
Answer the question
In order to leave comments, you need to log in
function getAjaxResult(url, data = null) {
return $.get(url, { data });
}
$('.btn').click(function () {
getAjaxResult('/get_products_select_count').then(function (data) {
alert(data);
});
});
$('.btn').click(async function () {
const data = await getAjaxResult('/get_products_select_count');
alert(data);
});
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question