qlixes

AJAX pak Tri

Sep 3rd, 2018
128
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <style type="text/css" media="screen">
  2.     .ui-autocomplete { z-index:999999; }
  3.     #birthday{z-index:1151 !important;}
  4.     #picurl { border: 1px #ff812e solid; min-width: 100px; border-radius: 5px; margin: 10px 0px 10px 0px;}
  5. </style>
  6. <form id="form" role="form" action="" method="post" enctype="multipart/form-data">
  7.     <input type="hidden" name="id" value="i">
  8.     <div class="modal-header">
  9.         <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
  10.         <h4 class="modal-title" id="myModalLabel"><?php echo $subTitle; ?></h4>
  11.     </div>
  12.     <div class="modal-body">
  13.         <div class="row">
  14.             <div class="row col-lg-12">
  15.                
  16.                 <div class="col-md-8">
  17.                 <label for="category_name">Category Name (English)</label>
  18.                 <input type="text" class="form-control" name="category_name" id="category_name" required placeholder="Enter Category (English)">
  19.                 </div>
  20.  
  21.                 <div class="col-md-4">
  22.                 <label for="sort_seq">Sort Sequence No.</label>
  23.                 <input type="number" class="form-control" name="sort_seq" id="sort_seq" required placeholder="Enter sequence number" value="<?php echo $records->sort_seq+1 ?>">
  24.                 </div>
  25.  
  26.                 <div class="col-md-8">
  27.                 <label for="category_name_km">Catagory Name (Khmer)</label>
  28.                 <input type="text" class="form-control" name="category_name_km" id="category_name_km" required placeholder="Enter Category (Khmer)">
  29.                 </div>
  30.  
  31.                 <div class="col-md-8">
  32.                 <label for="category_name_cn">Category Name (China)</label>
  33.                 <input type="text" class="form-control" name="category_name_cn" id="category_name_cn" placeholder="Enter Category (China)">
  34.                 </div>
  35.  
  36.                 <!-- <div class="col-md-8">
  37.                 <label for="category_name_kr">Tags Name (Korea)</label>
  38.                 <input type="text" class="form-control" name="category_name_kr" id="category_name_kr" required placeholder="Enter Category (Korea)">
  39.                 </div>
  40.  
  41.                 <div class="col-md-8">
  42.                 <label for="tags_name_jp">Category Name (Japan)</label>
  43.                 <input type="text" class="form-control" name="category_name_jp" id="category_name_jp" required placeholder="Enter Category (Japan)">
  44.                 </div> -->
  45.  
  46.                 <div class="col-md-12">
  47.                 <label for="catimage">Category Image</label>
  48.                 <input type="file" name="catimage" >
  49.                 </div>
  50.  
  51.             </div>
  52.  
  53.  
  54.             <div class="col-md-12">&nbsp;</div>
  55.             <div class="col-md-12">&nbsp;</div>
  56.         </div>
  57.     </div>
  58.    
  59.     <div class="modal-footer">
  60.         <button type="button" class="btn btn-danger pull-left" data-dismiss="modal">
  61.         <i class="glyphicon glyphicon-remove"></i> Close
  62.         </button>
  63.         <button type="submit" class="btn btn-success save">
  64.         <i class="glyphicon glyphicon-ok"></i> Save data</button>
  65.     </div>
  66.  
  67. </form>
  68.  
  69. <script type="text/javascript">
  70.     var processSave = false;
  71.     $(document).ready(function () {
  72.  
  73.         $('#form').submit(function (event) {
  74.             if(processSave == false){
  75.                 processSave = true;
  76.                 event.preventDefault();
  77.                 var btn = $('.save');
  78.                 btn.button('loading');
  79.                 var fd = new FormData($('#form')[0]);
  80.  
  81.                 $.post("<?php echo site_url('xmall/save_master_category'); ?>", $(this).serialize(), function (data, textStatus, xhr) {
  82.                     if(data.status == 'true'){
  83.                         bootbox.alert(data.message, function() {
  84.                             console.log("execute save");
  85.                             $.ajax({
  86.                                 type: 'post',
  87.                                 url: "<?php echo site_url("xmall/upload_pic_mall_category"); ?>/"+ data.id,
  88.                                 data: fd,
  89.                                 processData: false,
  90.                                 contentType: false,
  91.                                 success: function (d) {
  92.                                     processSave = false;
  93.                                     $('#myModal').modal('hide');
  94.                                     window.location.reload();
  95.                                 }
  96.                             });
  97.                         });
  98.                     }else{
  99.                         bootbox.alert(data.message, function() {
  100.                             btn.button('reset');
  101.                             processSave = false;
  102.                         });
  103.                     }
  104.                 }, 'json')
  105.                 .fail(function() {
  106.                     bootbox.alert("proccessing error", function() {
  107.                         btn.button('reset');
  108.                         processSave = false;
  109.                     });
  110.                 });
  111.             }
  112.         });
  113.     });
  114. </script>
Add Comment
Please, Sign In to add comment