( function( $ ) {
  "use strict";  
jQuery(document).ready(function($){ 

     $(document).on('click', '.jws-make-features', function(e) {
            var Id = $(this).data('id'),
                btn = $(this);
     
            btn.toggleClass('active');
            var data = {
            id: Id,
            action: "jws_ajax_load_make_features",  
            };
            $.ajax({
                url: ajaxurl,
                data: data,
                method: 'get',
                success: function(data) {
                    console.log(data);
                },
                error: function() {console.log('error');},
            });
      });
      
      $(document).on('change', '.jws_cars_user_list_ad input', function() {
          var status = 'pu';
          var $this = $(this);   
          var id = $(this).parents('span').data('id'); 
          if(this.checked) {
            status = 'pu';
          }else {
            status = 'pen';
          }


		$.ajax({
			url: jws_script.ajax_url,
			type: 'post',
			dataType: 'json',
			data: 'action=jws_change_status_cars_form_user&status='+status+'&id='+id+'',
			beforeSend: function() {
				$this.parents('span').addClass('loading');
			},
			success: function(response) {
			 console.log(response);
				$this.parents('span').removeClass('loading');
			},
			error: function() {
				alert('Something went wrong!');
				$this.parents('span').removeClass('loading');
			}
		});
		return false;
	});
      
});
    
} )( jQuery );      