Skip to content

Instantly share code, notes, and snippets.

@asadaly111
Last active August 17, 2017 11:50
Show Gist options
  • Save asadaly111/4ce70232229ba0e094ba2f23368d5933 to your computer and use it in GitHub Desktop.
Save asadaly111/4ce70232229ba0e094ba2f23368d5933 to your computer and use it in GitHub Desktop.
Jquery snipets and Sweat Alert for the Notifications functions
//Ajax Delete
swal({
title: "Are you sure ?",
text: "Are you sure you want to delete this Voucher?",
type: "info",
showCancelButton: true,
closeOnConfirm: false,
showLoaderOnConfirm: true,
}, function(){
setTimeout(function(){
swal("Deleted Successfully");
}, 3000);
});
<!--popover html -->
<td><a href="#" class="quantity_" data-id="<?= $key1['id'];?>" data-toggle="popover" data-container="body" data-placement="top" title="" data-content="" data-original-title="Quantity" aria-describedby="popover672609"><?= $key1['Qty'];?></a></td>
<!--popover jquery on hover -->
$('.quantity_').hover(function(event) {
var tt = $(this);
var v = $(this).data('id');
var t = $(this).attr('aria-describedby');;
console.log(v);
console.log(t);
$.post('script2.php', {quantitycheck : v }, function(value) {
// $('#'+t).find('.popover-content').html(value);
tt.popover({
"html": true,
content: value
}).popover('show');
});
}, function() {
$(this).popover('destroy');
});
$('#ajaxfilter').submit(function(event) {
event.preventDefault();
$.LoadingOverlay("show");
var formData = new FormData($(this)[0]);
var url = $(this).attr('action');
$.ajax({
type: 'post',
url: url,
contentType: false,
processData: false,
data: formData,
})
.done(function(value) {
$.LoadingOverlay("hide");
$('.fetchdatahere').html(value);
})
.fail(function() {
console.log("error");
});
});
$(document).on('click', '.pagination li a:not(.not)', function(event) {
event.preventDefault();
$.LoadingOverlay("show");
var href = $(this).attr('href');
$.post(href, { param1: 'value1'}, function(value) {
$.LoadingOverlay("hide");
$('.fetchdatahere').html(value);
});
});
$(document).on('click', '.reset', function(event) {
event.preventDefault();
$('#ajaxfilter').trigger('reset');
});
jQuery(document).on('submit', '.cartwoo', function(event) {
event.preventDefault();
var formData = new FormData(jQuery(this)[0]);
var url = jQuery(this).attr('action');
jQuery.ajax({
type: 'post',
url: url,
contentType: false,
processData: false,
data: formData,
})
.done(function(value) {
console.log(wc_add_to_cart_params.ajax_url);
})
.fail(function() {
console.log("error");
});
});
jQuery(document).on('submit', '.cartwoo', function(event) {
event.preventDefault();
var formData = new FormData(jQuery(this)[0]);
var url = jQuery(this).attr('action');
jQuery.ajax({
type: 'post',
url: url,
contentType: false,
processData: false,
data: formData,
})
.done(function(value) {
console.log(wc_add_to_cart_params.ajax_url);
})
.fail(function() {
console.log("error");
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment