PluginProbe
MxChat – AI Chatbot & Content Generation for WordPress / 1.0.10
MxChat – AI Chatbot & Content Generation for WordPress v1.0.10
3.2.21 3.2.20 3.2.19 3.2.18 3.2.17 3.2.16 3.2.15 3.2.14 3.2.12 3.2.13 3.2.11 3.2.10 3.2.9 3.2.8 3.2.7 3.2.6 3.2.5 3.2.4 3.2.3 3.2.2 3.2.1 2.0.3 2.0.4 2.0.5 2.0.6 All 152 releases
mxchat-basic / js / activation-script.js

activation-script.js in MxChat – AI Chatbot & Content Generation for WordPress 1.0.10, at js/activation-script.js

48 lines 1.8 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 document.getElementById('mxchat-activation-form').addEventListener('submit', function(e) {
2 e.preventDefault(); // Prevent the form from submitting the normal way
3
4 var spinner = document.getElementById('mxchat-spinner');
5 var submitButton = document.getElementById('activate_license_button');
6 var licenseStatus = document.getElementById('mxchat-license-status');
7
8 // Show the spinner and disable the submit button
9 spinner.style.display = 'inline-block';
10 submitButton.disabled = true;
11
12 // Gather form data
13 var formData = new FormData(this);
14
15 // Send the AJAX request
16 var xhr = new XMLHttpRequest();
17 xhr.open('POST', mxchatChat.ajax_url, true);
18 xhr.setRequestHeader('X-Requested-With', 'XMLHttpRequest');
19 xhr.onload = function() {
20 // Hide the spinner and re-enable the submit button
21 spinner.style.display = 'none';
22 submitButton.disabled = false;
23
24 if (xhr.status >= 200 && xhr.status < 400) {
25 var response = JSON.parse(xhr.responseText);
26 if (response.success) {
27 // Update the license status to active
28 licenseStatus.textContent = 'Active';
29 licenseStatus.classList.remove('inactive');
30 licenseStatus.classList.add('active');
31 } else {
32 // Handle the error case
33 alert(response.data.message || 'There was an error activating the license.');
34 }
35 } else {
36 // Handle server error
37 alert('Server error. Please try again.');
38 }
39 };
40
41 xhr.onerror = function() {
42 // Handle connection error
43 alert('Request failed. Please check your internet connection.');
44 };
45
46 xhr.send(new URLSearchParams(formData).toString()); // Send the form data
47 });
48