Powered By Blogger

Tuesday, June 30, 2015

form data send to controller or function using AJAX

<button class="btn btn-primary btn-xs" id="rmv" onclick="remove_product_image('<?php echo md5($product_details['product_id']);?>');" type="button">Remove</button>

<script>
function remove_product_image(id)
{
if(confirm('Are you sure of deleting image?'))
{

form_data={product_id:id};

$.ajax({

url: "<?php echo base_url().'product/product_image_delete/' ?>",
type: 'POST',
async : true,
data:form_data,      
success: function(msg) {
 
  if(msg==1)
{
$( "#remove_img" ).hide();
$( "#pimage").show();
$( "#pimage").val('');
$("#rmv").hide();
$("#pimage").show();
}  
  showNotification({
                        message: "Image has been deleted successfully!.",
                        type: "success" ,
                        autoClose: true,
                        duration: 5
                    });
}
});
}

}

</script>

No comments:

Post a Comment