javascript - Classes is making image load under all results in while loop -


here loading image below submit button being displayed on results in while loop when click on of submit button generated while loop. should displayed below clicked button only. know happening because have used classes here. think should use unique ids here result gets displayed below particular clicked button only. not sure how accomplish this. or should use other method here? please have look.

<?php while($a = $stmt->fetch()){ extract($a); ?>     <form method="post" action="">         <input type="hidden" value="<?php echo $mbs_id; ?>" class="memid">         <select class="validity" class="upgrade-valsel">             <?php while($mv = $mval->fetch()){ extract($mv); ?>                 <option value="<?php echo $mv_id; ?>"><?php echo $mv_validity; if($mv_validity == 1){ echo " month"; }else{ echo " months"; } ?></option>             <?php } ?>         </select>         <input type="submit" value="upgrade" class="submit">         <div class="center-align" style="margin-left: -20px"><img src="images/loading.gif" width="auto" id="loading-rent" class="loading-rent" style="margin-right: 0px; height: 40px"></div>     </form> <?php } ?> 

script

$(document).ready(function() {     $(".submit").click(function () {         var datastring = {             memid: $(this).parent().find(".memid").val(),             memname: $(this).parent().find(".memname").val(),             validity: $(this).parent().find(".validity").val()         };         $.confirm({             title: 'confirm!',             content: 'are sure want upgrade membership ' + datastring.memname + '?',             buttons: {                 confirm: function () {                     $.ajax({                         type: "post",                         datatype: "json",                         url: "upgrade-process.php",                         data: datastring,                         cache: true,                         beforesend: function () {                             $("#submit").hide();                             $(".loading-rent").show();                             $(".message").hide();                         },                         success: function (json) {                             settimeout(function () {                                 $(".message").html(json.status).fadein();                                 $("#submit").show();                                 $(".loading-rent").hide();                             }, 1000);                         }                     });                 },                 cancel: function () {                     $.alert('<span style="font-size: 23px">upgrade cancelled!</span>');                 }             }         });         return false;     }); }); 

you need find loader localy @

var $loader = $(this).parent().find('.loading-rent');

 $(document).ready(function() {   $(".submit").click(function () {     var datastring = {         memid: $(this).parent().find(".memid").val(),         memname: $(this).parent().find(".memname").val(),         validity: $(this).parent().find(".validity").val()     };      var $loader = $(this).parent().find('.loading-rent');      $.confirm({         title: 'confirm!',         content: 'are sure want upgrade membership ' + datastring.memname + '?',         buttons: {             confirm: function () {                 $.ajax({                     type: "post",                     datatype: "json",                     url: "upgrade-process.php",                     data: datastring,                     cache: true,                     beforesend: function () {                         $("#submit").hide();                         $loader.show();                         $(".message").hide();                     },                     success: function (json) {                         settimeout(function () {                             $(".message").html(json.status).fadein();                             $("#submit").show();                             $loader.hide();                         }, 1000);                     }                 });             },             cancel: function () {                 $.alert('<span style="font-size: 23px">upgrade cancelled!</span>');             }         }     });     return false; }); 

});


Comments

Popular posts from this blog

php - Permission denied. Laravel linux server -

google bigquery - Delta between query execution time and Java query call to finish -

python - Pandas two dataframes multiplication? -