2016-09-22 13 views
1

새로 고침 후 나는 아약스 카트입니다이 모달부트 스트랩 모달 내용 문제 내용

<!-- Modal --> 
<div id="normale" class="modal fade" role="dialog"> 
    <div class="modal-dialog" style="background-color:white"> 

    <!-- Modal content--> 
    <div class="modal-content" style="background-color:white"> 
     <div class="modal-header" style="background-color:white"> 
     <button type="button" class="close" data-dismiss="modal">&times;</button> 
     <h4 class="modal-title">Aggiungi al carrello</h4> 
     </div> 
     <div class="modal-body" id="mod_carrello" style="background-color:white"> 
     <div class="hidden"> 
      <input type="text" id="id_tariffa" name="id_tariffa" value="id_tariffa" readonly class="form-control hidethis" style="display:none" > 
     </div> 
     <div class="form-group hidethis " style="display:none" > 
      <label for="Id" class=" control-label col-md-4 text-left"> Id </label> 
        <div class="col-md-6"> 
         <input type="text" id="id" name="id"> 
        </div> 
        <div class="col-md-2"> 

        </div> 
        </div>   
        <div class="form-group hidethis " style="display:none"> 
        <label for="Cod Carrello" class=" control-label col-md-4 text-left"> Cod Carrello </label> 
        <div class="col-md-6"> 
         <?php 
         $persistent = DB::table('carrello')->where('entry_by', \Session::get('uid'))->first(); 
         if (empty($persistent)) { 
         $chars = "abcdefghijkmnopqrstuvwxyz023456789"; 
         srand((double)microtime()*1000000); 
         $i = 0; 
         $code = '' ; 
         while ($i <= 20) { 
         $num = rand() % 33; 
         $tmp = substr($chars, $num, 1); 
         $code = $code . $tmp; 
         $i++; } ?> 
         <input type="text" name="cod_carrello" value="{{ $code }}" id="cod_carrello"> 
        <?php } else { 
         $cod_carrello = $persistent->cod_carrello; ?> 
         <input type="text" name="cod_carrello" value="{{ $cod_carrello }}" id="cod_carrello"> 
        <?php } ?> 
        </div> 
        <div class="col-md-2">     
        </div> 
        </div>    
        <div class="form-group " > 
        <label for="Quantita" class=" control-label col-md-4 text-left"> Quantita </label> 
        <div class="col-md-6"> 
         <input type="text" class="form-control" id="quantita" name="quantita"> 
        </div> 
        <div class="col-md-2"> 
        </div> 
        </div>    
       </fieldset> 
       </div> 
      <div class="modal-footer" style="background-color:white"> 
     <button type="submit" id="add_to_cart" class="btn btn-assertive">Aggiungi</button> 
     <button type="button" class="btn btn-default" data-dismiss="modal">Chiudi</button> 
     </div> 
    </div> 
    </div> 
</div> 

있습니다. 이것은 Jquery 스크립트입니다.

$('#add_to_cart').click(function(){ 
    var button = $(event.relatedTarget) // Button that triggered the modal 
    var id_tariffa = button.data('tariffa') 
    // If necessary, you could initiate an AJAX request here (and then do the updating in a callback). 
    // Update the modal's content. We'll use jQuery here, but you could use a data binding library or other methods instead. 
    var modal = $(this) 
    modal.find('.hidden input').val(id_tariffa); 
    var cod_carrello = document.getElementById("cod_carrello").value; 
    var quantita = document.getElementById("quantita").value; 
$.ajax({ 
    url: 'carrello-ajax', 
    type: "post", 
    data: {'id_tariffa':id_tariffa, 'cod_carrello':cod_carrello, 'quantita':quantita, '_token': $('input[name=_token]').val()}, 
    success: function(data){ 
    if (data.OK == 1) { 
    var mod_carrello_original = $("#mod_carrello").html(); 
    $('#mod_carrello').html('<h1 align="center" style="color:green; font-size: 21.5em;"><i class="fa fa-smile-o"></i></h1><br><br><h3 align="center">Servizio aggiunto correttamente al carrello</h3>'); 
    $("#normale").on("hidden.bs.modal", function(){ 
     $('#mod_carrello').html(mod_carrello_original); 
    }); 
     } else { 
    $('#mod_carrello').html('<h1 style="color:green"><i class="fa fa-error"></i><br>Si è verificato un errore</h2>');  
     }  
    } 
    }); 
});  

}});

제 문제는 2 시간 후에 아무 문제없이 제품을 입력하고 추가 할 수있는 문제입니다. 모달은 더 이상 내용을 업데이트하지 않고 성공 메시지를 보여줍니다. 누군가가 나를 도울 수 있기를 바랍니다.

답변

0

다른 콘텐츠와 동일한 ID를 사용하여 새로운 div를 사용하여 해결