Hi
I am using jquery confirm
https://craftpip.github.io/jquery-confirm/
I am getting Uncaught TypeError: $.confirm is not a function - when I directly put the below code -
$.confirm({
title: 'Congratulations!',
content: result.message,
type: 'green',
buttons: {
omg: {
text: 'Thank you!',
btnClass: 'btn-green',
},
close: function () {
}
}
});``
in success:function()
here is my whole code:
jQuery(document).ready(function(){
jQuery('#ajaxLike').click(function(e){
e.preventDefault();
$.ajaxSetup({
headers: {
'X-CSRF-TOKEN': $('meta[name="_token"]').attr('content')
}
});
jQuery.ajax({
beforeSend: function(){
if(confirm("Are you sure you want to submit the value ?"))
return true;
else
return false;
},
url: "{{ url('/users/like') }}",
method: 'post',
data: {
userid: jQuery('#userId').val()
},
/*success: function(result){
console.log(result);
}});*/
success: function(result){
jQuery('#likeCount').text(result.kbc);
jQuery('#ajaxLike').replaceWith('<button class="btn btn-info" id="ajaxLike" disabled="disabled"><i class="fa fa-thumbs-up" style="font-size:16px"></i> You Liked</button>');
$.confirm({
title: 'Congratulations!',
content: result.message,
type: 'green',
buttons: {
omg: {
text: 'Thank you!',
btnClass: 'btn-green',
},
close: function () {
}
}
});
}
});
});
});
I think I am putting the $.confirm code wrong way, it should be put inside something to work.
I am not well versed in jquery and all these.
Otherwise my code is working fine submitting the request with ajax.
Can someone suggest me please what I am doing wrong
Thanks in advance