I have a piece of code that requests a list of items using the getjson method. The controller verb method returns the list of objects correctly. Data has been requested after downloading the app in the code given below, but it is invisible / transparent data which means that it is adding my data but not visible So, it's white / transparent. Here's the code:
& lt; Script & gt; $ (Document) .ready (function () {$ ('# b1'). Click (function () {var userName = "Hello" $ .getJSON ("/ classes / getCourseList? Username =" + userName, function (data1 ) {Var myOptions = {val1: data1.title}; var $ mySelect = $ ('# s1'); $ .eich (my option, function (val, text) {$ mySelect.append ($ ('$ (& lt; Option / & gt; ', {value: val, text: text}));})}});});}); & Lt; / Script & gt;
Action method:
[AllowAnonymous] Public JsonResult getCourseList (string username) {// quiz q = new quiz (); // q = _db.Quizzes.FirstOrDefault (x => x.QuizName.Equals (userName)); & Lt; DummyCourses & gt; List = new list & lt; Dummy Corace & gt; (); Foreign Language (Course C in DB Course) {Dummy Corrors DC = New Dummy Corus (); Dc.title = c.title; Dc.creditHours = c.creditHours; Dc.instructor = c.instructor; Dc.code = c.code; List.Add (DC); } Return to this Jason (The list, J. S. Be like you structure: [
I mean the array of objects, but you data1.title
(this will be undefined
in your code
this data 1 [0] .title
, data 1 [1] ] .title should be
, etc.
No comments:
Post a Comment