Hello friends,
How to access viewbag content in external javascript file
i am facing issue while appending viewbag data to div tag
my controller code:
ViewBag.referenceCrisisList = html;
cshtml view code:
<table id="maintable"> <thead> <tr> <th>Line</th>
</tr>
</thead> <tbody>
</tbody>
</table>
Javascript file code:
$(document).ready(function () {
var html = '@ViewBag.referenceCrisisList';
$("#maintable tbody").html(html);
}
Its Working only when directly put js code inside cshtml. not working when handling js code from js file.
please help
i separated javascript code from view now its not working.