How to use model popup using ajax? Can any one help for this. Here below my code. How can i apply in this code model popup? And also post data get in popup. How it possible?
app/code/Vendor/Complany/view/frontend/web/js/example.js
define([
'jquery',
'Magento_Ui/js/modal/modal'
], function ($,example,modal) {
return {
exampleData:function(ajaxurl){
$("#example").click(function(e){
e.preventDefault();
$.ajax({
url:ajaxurl,
type:'POST',
showLoader: true,
dataType:'json',
success:function(){
alert('test');
}
});
});
}
}
}
);
app/cpde/Vendor/Company/view/frontend/templates/example/example.phtml
<div id="events_popup" style="display: none;" class="events_popup">
<script>
require(
['jquery','Vendor_Company/js/example'],
function($,example){
var ajaxurl = '<?php echo //My URL using block function; ?>';
example.exampleData(ajaxurl);
}
);
</script>