I use YAHOO.util.Connect.asyncRequest to get data from a database, here is the code:
function getCountArticle(contentCurValue) { var handleSuccess = function (res) { var countPubmed = YAHOO.lang.JSON.parse(res.responseText); var contentCountPubmed = countPubmed.totalArticleRecords; alert(contentCountPubmed);
I would like this function to return: "contentCurValue" (for example: 15), but when I try to use this code, I get "undefined":
var test = getCountArticle(); alert(test); // return undefined, should return 15
My error is probably related to an asynchronous request, but how can I get "var test = getCountArticle ()"; to wait for the results ?
source share