javascript - Html table row not appending to specified table -


I am trying to add json string to an HTML table. I object data is correct but this table is not attached to me

  GetSongs (id) {$ .ajax ({type: "go", url: "@ Url.Action (" GetSongs ",). "Play"), "data: {playlistId: id}, success: work (data) for {json = data; obj = JSON.parse (json); (var i = 0; i & lt; data.length; I ++) {$ ('# song-table'). Endend ('& lt; tr & gt;' + htmlEncode (obj [i]. Song URL) ''  ')}} }}); }   

HTML table:

  & lt; Div id = "player-playlist" & gt; & Lt; Table id = "song-table" style = "width: 420px" & gt; & Lt; TR & gt; & Lt; Th & gt; Song & lt; / Th & gt; & Lt; / TR & gt; & Lt; TR & gt; & Lt; TD & gt; Http: //www.youtube.com/v/CFF0mV24WCY< / TD & gt; & Lt; / TR & gt; & Lt; / Table & gt; & Lt; / Div & gt;    

delete htmlEncode () because it is not defined by your JS, define or remove it

 for  (var i in obj) {$ ("# song-table"). Annexe (" Tt>" + obj [I]. + Songral + " "); } {$ ("# Song-table") for   

or

  (in obj me i) Attached ("& lt; tr> " + htmlEncode (obj [i]. Song URL + " "); } Function htmlEncode (string) {var pre = document.createElement ('pre'); Var text = document.createTextNode (string); Pre.appendChild (text); Before return. HIL; } // and HTML avoids this encoding HTML    

Comments

Popular posts from this blog

c - Mpirun hangs when mpi send and recieve is put in a loop -

python - Apply coupon to a customer's subscription based on non-stripe related actions on the site -

java - Unable to get JDBC connection in Spring application to MySQL -