Advertisement
Guest User

Untitled

a guest
Apr 25th, 2017
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
jQuery 0.81 KB | None | 0 0
  1.     jQuery('.brid').click(function(){
  2.  
  3.         count = jQuery('#yesfav').children().length;
  4.  
  5.         var brand_id = jQuery(this).attr('id');
  6.         var status = jQuery(this).attr('checked');
  7.         var url = "<?=$this->getUrl('brands/index/brands')?>";
  8.         console.log('Brand: '+brand_id+' '+status+' '+url);
  9.        
  10.         jQuery.ajax({
  11.             url: "<?=$this->getUrl('brands/index/brands')?>",
  12.             type: 'POST',
  13.             dataType: 'JSON',
  14.             method: 'update',
  15.             data:{
  16.                 'brand_id': brand_id,
  17.                 'status': status,
  18.             },
  19.             success: function(data) {
  20.                 if(data.status == '1'){
  21.                     jQuery('div[name='+data.brand+']').appendTo('#yesfav');
  22.                     counter();
  23.                 }else{
  24.                     jQuery('div[name='+data.brand+']').appendTo('#notfav');
  25.                     counter();
  26.                 }
  27.             },
  28.             error: function(data) {
  29.                 console.log('Error! - Nothing received!');
  30.             },
  31.         });
  32.     });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement