title: Viewbag in Javascript shows error Uncaught SyntaxError: Unexpected token '<'
body: <p>I am fetching the data using API and assign it to VIEW BAG but at run time it shows me an error.</p>
  <pre><code>List&lt;DevInfo&gt; DevList = await RestApi.Instance.GetAllDevAsync();
  var nameT = DevList.Select(a=&gt;a.Name).ToList();
  ViewBag.datasourceDevList = nameT;
  </code></pre>
  <p>And in the script.</p>
  <pre><code>var nameList = &lt;%= new JavaScriptSerializer().Serialize(&quot;@ViewBag.datasourceDevList&quot;) %&gt;;
  
  </code></pre>
  <p>I want to generate the dropdown list.</p>
  <pre><code>if (nameList != '') {
                  var tableHtml;
                  $.each(JSON.parse(nameList), function (index, value) {
                      //tableHtml += &quot;&lt;option value=&quot; + value.Name + &quot;&gt;&quot; + value.Name + &quot;&lt;/option&gt;&quot;;
                      console.log(value);
                  });
                  /*$(&quot;#selectTrainer&quot;).html(tableHtml);*/
                  $(&quot;#selectTrainer&quot;).append(tableHtml);
  }
  </code></pre>