location.reload没有重新加载

时间:2016-07-01 06:06:33

标签: javascript ajax codeigniter reload

当我浏览图像时,我想在我的网页上同时显示图像。因为我使用了这段代码,但图像没有显示,当我刷新页面时图像显示,我想我的location.reload()函数无效,这就是为什么它无法正常工作 这是我的剧本

<script type="text/javascript">
$(document).ready(function (){
//alert();
$('#modal-close').click();
$("#file").change(function() { $('#upload-image').submit(); });
$('#upload-image').on('submit',(function(e){
 e.preventDefault();
           //alert()
           var formData = new FormData(this);
           $.ajax({
            type:'POST',
            url: $(this).attr('action'),
            data:formData,
            cache:false,
            contentType: false,
            processData: false,
            success:function(result)
           {

                  $('#uploaded-img').html(result);

                  window.location.reload(true);

                }
                });
         }));

});

这是我的观点

<div class="col-md-4" style="padding:0px;">
<div class="add-vehcle-image" >
     <form id="uploaded-img"> 

       <!-- added imges contain here  -->
       <?php if($this->session->userdata('image')){
       foreach ($this->session->userdata('image') as $row)
        {?>
          <div class="col-md-12 col-xs-12 col-sm-12 upload-img">
             <img class='img-responsive img-thumbnail' alt='Image' src="<?php echo base_url();?>uploads/thumb/<?php echo $row; ?>">
                 <div image="<?php echo $row;?>" class="close-btn" data-toggle="modal" data-target="#confirm" >
                     <span data-toggle="tooltip" data-placement="bottom" title='Delete' class="fa fa-close">
                     </span>
                     <i class="fa fa-times"></i>
                 </div>
          </div>
         <?php } } ?>
     </form>


</div>
      <div class="col-md-12" style="margin-top: 24px;">
       <div class="add-vehcle-image">
         <form enctype="multipart/form-data" method="POST" action="<?php echo base_url();?>admin_control/upload_image" id="upload-image">
          <div class="form-group upload-image">
           <input type="file" data-toggle="tooltip" data-placement="bottom" title="Upload Image" name="file" id="file" >

         </div>
         <input name="id" type="hidden" value="<?php echo $result->id; ?>" 
         id='product_id'>                
         <input name="table" type="hidden" value="results" id="table">
       </form>
     </div>
   </div>
 </div> 

0 个答案:

没有答案