Good day Everyone,
I am currently facing an issue with a javascript variable in my view. This is what I have been trying to do...
var skinData = null;
and then, when the document is ready....
$.ajax({
type: 'POST',
url: 'theme/getskins',
data: {},
contentType: 'application/json; charset=utf-8',
success: function(data){
skinData = data;
}
});
I am wondering why I am executing this after the view has already loaded. Is there a way I can move this logic to _ViewStart.cshtml?
viewPage.ViewBag.SkinInfo = new JsonResult { Data = SkinManager.GetSkins() };
How can I extract this value and pass it to my javascript variable? I don't want to make another request when I can simply send this information to the client on the initial trip. Any suggestions or guidance would be greatly appreciated. How can I achieve this effectively? I have tried a few different approaches, like...
var skinData = @ViewBag.SkinInfo.Data;
However, this only outputs the namespace. Does anyone have a solution for this?
Thank you,
~ck from San Diego