jquery addClass not working after ajax call -


hello made code required add class after ajax call . sure code right still class not being added . strange else in code works , sure code addclass right have checked console errors there no errors . here code

$(document).on('click', '.miclickks', function(event) {  event.preventdefault();  var for_uid    = $(this).parents("li").attr('data'); var for_name   = $(this).parents("li").attr('unme'); var for_pic    = $(this).parents("li").attr('upic'); var owner_uid  = $('.row-fluid').attr('uid'); var owner_name = $('.row-fluid').attr('usnm'); var owner_pic  = $('.row-fluid').attr('usp'); var type       = "kiss";  var datastring = "type=" + type + "&for_uid=" + for_uid + "&for_name=" + for_name + "&for_pic=" + for_pic + "&owner_uid=" + owner_uid + "&owner_pic=" + owner_pic + "&owner_name=" + owner_name;           $.ajax({             type: "post",             url: "include/ajax.php",             data: datastring,             success: function (html) {             if(html=="300")             {             $('#mymodal .modal-body p').html("error please try again.");              $('#mymodal').modal('show');             }             else             {             $(this).addclass('active');                    }             }         });    }); 

two ways:

first:

var = this; $.ajax({     type: "post",     url: "include/ajax.php",     data: datastring,     success: function (html) {         if (html == "300") {             $('#mymodal .modal-body p').html("error please try again.");             $('#mymodal').modal('show');         } else {             $(that).addclass('active');         }     } }); 

second (use context option):

$.ajax({     type: "post",     url: "include/ajax.php",     data: datastring,     context: this,     success: function (html) {         if (html == "300") {             $('#mymodal .modal-body p').html("error please try again.");             $('#mymodal').modal('show');         } else {             $(this).addclass('active');         }     } }); 

Comments

Popular posts from this blog

SPSS keyboard combination alters encoding -

Add new record to the table by click on the button in Microsoft Access -

CSS3 Transition to highlight new elements created in JQuery -