Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var formData = new FormData(document.getElementById('emailForm'));
- formData.append("action", "sendEmail");
- // Override body to TinyMCE content
- formData.set("body", tinyMCE.activeEditor.getContent());
- formData.set("send_type", sendType);
- if (forwardedAttachments.filter(Boolean).length) {
- $(forwardedAttachments.filter(Boolean)).each(function (k, v) {
- formData.append("forwarded_attachments[]", v);
- });
- } else {
- formData.append("forwarded_attachments[]", []);
- }
- if (fileUploads.filter(Boolean).length) {
- $(fileUploads.filter(Boolean)).each(function (k, v) {
- formData.append("attachments[]", v);
- });
- }
- $(this).addClass('is-loading');
- $.ajax({
- url: 'ajax/sendEmail.php',
- type: "POST",
- data: formData,
- contentType: false,
- cache: false,
- processData: false,
- success: function (data) {
- $('#sendEmail').removeClass('is-loading');
- displayModal('success', 'Email Sent', 'The email has been sent successfully', true);
- setTimeout(function () {
- parent.window.close();
- }, 1500);
- },
- error: function (e) {
- let response = JSON.parse(jqXhr.responseText);
- if (response) {
- displayModal('error', response.title, response.message);
- }
- }
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement