So here is what i'm trying to do: I need to create an ajax call to the server, the return values from the ajax call will be the values that i want to add to the html page.
I willing to creating using pullReturnsProfiles
method the html tags with the data.
pullReturnsProfiles
should return the string that represent the html data that i will add to the view from the parent method that using pullReturnsProfiles
My problem is that pullReturnsProfiles
finished before the each iteration is finish and there for the return value is undefined from this method.
Is there any way to solve it instead of adding dynamically the html tags to an id/class ?
function pullReturnsProfiles()
{
returnProfiles= '';
retVal = pullinfo('val'); //retriving data from ajax call
retVal.success(function (data) {
$.each(data,function(key,val){
returnProfiles = returnProfiles.concat('<option value="'+val+'">'+key+'</option>');
})
console.log(returnProfiles);
return returnProfiles;
});
}