I am having a click event that triggers an ajax post and from that ajax post I want to wait until it is done and get the return value from the post to be accessed in the click event. What I tried is below:
$("#tblInventory").on('click', '.user_action', function() {
//I want to access the returned data of the function here
$.when(GetAttachments('material')).done(function(x) {
console.log(x); // still this is undefined
});
});
function GetAttachments(folder) {
var formdata = {};
var site_url = ;
$.post(site_url, formdata)
.done(function(response) {//i want to get this response
attachment_files = response;
console.log(response)//this console is ok
fnShowFiles(response)
return response;//i even tried returning the value
})
}
Comments
Post a Comment