how to put variable inside append jquery -


script

javascript how put variable inside in append

    $(function () {         $(window).load(function () {             $.ajax({                 url: "/menu/getpagemenu",                 type: "get",                 success: function (data) {                      (var = 0; < data.length; i++) {                         var opt = new option(data[i].title, data[i].id);                                                     $('#target').append('<input type ="checkbox" name="menu">' + opt+ '</input>');                     }                  }              });         });     }); 

enter image description here

data not showing.

you can try this:

$(function () {         $(window).load(function () {             $.ajax({                 url: "/menu/getpagemenu",                 type: "get",                 success: function (data) {                      (var = 0; < data.length; i++) {                         //var opt = new option(data[i].title, data[i].id);                                                     $('#target').append('<input type ="checkbox" name="menu" value="'+data[i].id+'">' + data[i].title+ '</input>');                     }                  }              });         });     }); 

Comments

Popular posts from this blog

android - InAppBilling registering BroadcastReceiver in AndroidManifest -

python Tkinter Capturing keyboard events save as one single string -

sql server - Why does Linq-to-SQL add unnecessary COUNT()? -