I have created Popup modal form, the form is successfully submitted and showing response, but after showing response I need to close the popup modal but failed to close the popuup modal
js file
define([
"jquery",
"jquery/ui",
"Magento_Ui/js/modal/modal"
],
function ($) {
"use strict";
// Review form
var xxx = {
type: 'popup',
responsive: true,
innerScroll: true,
buttons: false,
title: "aaa",
modalClass: "popup-center",
clickableOverlay: true,
};
var abc = $('#form-div-id').modal(xxx);
$(".link").click(function () {
abc.modal("openModal");
});
return function (config) {
$('#review-form').on("click", "#review-submit", function () {
var form_data = $("#review-form").serialize();
var reviewurl = config.url;
$.ajax({
url: reviewurl,
type: 'POST',
// Pass the submitted form data to Controller
data: form_data,
success: function (response) {
var returnedData = JSON.parse(response);
if (returnedData.status === 'success')
$("#success").html(returnedData.messages);
else
$("#error").html(returnedData.messages);
},
error: function (response) {
var returnedData = JSON.parse(response);
$("#error").html(returnedData.messages);
}
});
var close = this;
setTimeout(function () {
close.closeModal();
}, 3000);
return false;
});
};
});