how to handle two function
Question by Rohit Khurana
I have two funtions searching
and searchhistory
. Currently these two function are running in my code but the value of nbofimages
is not updated.
Also it’s showing only one alert message after searchhistory function is completed.
$.when(searching(searchkwd, check_st, check_sf, '31', '1', filter, ori, colorcheck))
.then(searchhistory(user_search,search_pars,search_username,nbofimages));
var nbofimages;
function searching(searchkwd, check_st, check_sf, '31', '1', filter, ori, colorcheck)
{
nbofimages = "3";
alert(nbofimages);
}
function searchhistory(user_search,search_pars,search_username,nbofimages)
{
alert(nbofimages);
}
Answer by Starx
Function passed to $.when
requires a promise to be returned.
function searching(searchkwd, check_st, check_sf, '31', '1', filter, ori, colorcheck)
{
nbofimages = "3";
alert(nbofimages);
return true;
}