Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $('#verif').on('click', function(){
- var item_number = $('#ch_item_number').val();
- var name = $('#ch_name').val();
- var lot = $('#ch_lot').val();
- var side = $('#ch_side').val();
- const file = document.querySelector('#fileexcel');
- var fileexcel = file.files[0].name;
- if(side == ''){
- error_firstname = 'please select side';
- alert(error_firstname);
- }else{
- $("#frm-verifikasi").on("submit", function(){
- event.preventDefault();
- // CSRF Hash
- var csrfName = $('.txt_csrfname').attr('name'); // CSRF Token name
- var csrfHash = $('.txt_csrfname').val(); // CSRF hash
- // var formData = new FormData(this);
- var dataJson = {
- [csrfName]: csrfHash,
- item_number : $('#ch_item_number').val(),
- name : $('#ch_name').val(),
- lot : $('#ch_lot').val(),
- side : $('#ch_side').val(),
- fileexcel : file.files[0].name
- };
- // alert(fileexcel);
- // alert(name);
- $.ajax({
- url: "<?php echo base_url('/import_cek'); ?>",
- type: "post",
- data: dataJson,
- dataType: "json",
- success: function(data)
- {
- console.log(data.format_name);
- console.log(data.name_ex);
- console.log(data.nama);
- console.log(data.product_name);
- // Update CSRF Token
- $('.txt_csrfname').val(data.token);
- // console.log(data.respon);
- if(data.respon == 'PASS'){
- // Display a success toast, with a title
- toastr.success('File sesuai', 'Info:');
- }else if(data.respon == 'FAIL'){
- toastr.error('File tidak sesuai', 'Info:');
- }
- },
- error: function (jqXhr, textStatus, errorMessage) { // error callback
- $('p').append('Error: ' + errorMessage);
- }
- });
- return false;
- });
- }
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement