I did ajax call and got response in callback function like below:
var v="";
....
jq.post(contextPath + "/dmp/workspace/inlineCssExtraction", {
jsonForSaveInlineCss: JSON.stringify(styleArr)
}, function(data) {
v=data;
});
return v;
Problem I am facing is, I am getting empty value of v.
I think reason is, ajax response is taken long time and before this retun v; line is executed. Is there any way to resolve this issue?
Regards
You cannot do it this way …. AJAX is asynchronous – the return expression will get executed before the callback function
You could pass the data to a function which would be called on AJAX success