Post data json inside checkbox and images

Post data json inside checkbox and images

Hi this is my whole  js, i'm  building some edit products which is inside modal bootsrap

  1. $('.edit_button').on("click", function(e) {
  2.     var id = $(this).data('id');  
  3.      $.ajax({
  4.         url: base_url + "product/edit/"+id,
  5.         type: "GET",
  6.         dataType: "JSON",
  7.         success: function(data)
  8.         {
  9.        //i need to show data from database in checkbox and images in by name input type checkbox

  10.            $('[name="id_brand"]').val(data.id_brand);
  11.             $('[name="merk"]').val(data.name_brand);
  12.             $('[name="id_tipe"]').val(data.id_tipe);
  13.             $('[name="tipe"]').val(data.name_tipe);
  14.             $('[name="product_toko"]').val(data.product_toko);
  15.             $('[name="product_harga"]').val(data.product_harga);
  16.             $('[name="product_keterangan"]').val(data.product_keterangan);

  17.         
  18.             $('#modal_form').modal('show'); // show bootstrap modal when complete loaded
  19.             $('.modal-title').text('Edit Product'); // Set title to Bootstrap modal title
  20.  
  21.         },
  22.         error: function (jqXHR, textStatus, errorThrown)
  23.         {
  24.             alert('Error get data from ajax');
  25.         }
  26.  });
  27.       });

then i'm trying to make var for 

name_tipe but gpot errors


my problem is how can i put values from database inside checkbox or images, here is i'm trying to pu calues inside checkbox but got errors val is not defined  

  1. $.ajax({
    url: base_url + "product/edit/"+id,
    type: "GET",
    dataType: "JSON",
    success: function(data)
    {
    //here is data from database which will show in modal

    var name_tipe= val(data.name_tipe); //consider it for check bok
    if (name_tipe !=='') {
    alert('check box has value');
    $('.myCheckbox').prop('checked', true);
    }
    else

    {
    alert('check box has value');
    $('.myCheckbox').prop('checked', false);
    }

    });


Thanks