Advertisement
freddy0512

ajax json

Oct 30th, 2015
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.38 KB | None | 0 0
  1. //edit data product
  2. $('.edit_button').on("click", function(e) {
  3. var id = $(this).data('id');
  4. $.ajax({
  5. url: base_url + "product/edit/"+id, //get data then put in json
  6. type: "GET",
  7. dataType: "JSON",
  8. success: function(data)
  9. {
  10. val(data.foto) //here is images and i need to put in modal bootsrap, how can i do that !
  11. $('[name="product_status"]').val(data.product_status); //here is checkbox but checkbox doesn't checked
  12.  
  13.  
  14.  
  15. //it's all show up in modal bootsrap, only check box and images i don't know how to show in modal
  16. $('[name="id_brand"]').val(data.id_brand);
  17. $('[name="merk"]').val(data.name_brand);
  18. $('[name="id_tipe"]').val(data.id_tipe);
  19. $('[name="tipe"]').val(data.name_tipe);
  20. $('[name="product_toko"]').val(data.product_toko);
  21. $('[name="product_harga"]').val(data.product_harga);
  22. $('[name="product_keterangan"]').val(data.product_keterangan);
  23.  
  24. $('#modal_form').modal('show'); // show bootstrap modal when complete loaded
  25. $('.modal-title').text('Edit Product'); // Set title to Bootstrap modal title
  26.  
  27. },
  28. error: function (jqXHR, textStatus, errorThrown)
  29. {
  30. alert('Error get data from ajax');
  31. }
  32. });
  33. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement