completed the send SMS which uses the first client App API key
This commit is contained in:
@@ -57,34 +57,37 @@
|
||||
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/js/bootstrap.bundle.min.js" integrity="sha384-YvpcrYf0tY3lHB60NNkmXc5s9fDVZLESaAA55NDzOxhy9GkcIdslK1eN7N6jIeHz" crossorigin="anonymous"></script>
|
||||
<script src="{{ url('public/libs/jquery-3.2.1.min.js') }}"></script>
|
||||
<script src="{{ url('public/libs/jquery-confirm/jquery-confirm.min.js') }}"></script>
|
||||
<script src="https://cdn.jsdelivr.net/npm/sweetalert2@11"></script>
|
||||
|
||||
@yield('page-js')
|
||||
<script>
|
||||
const myForm = document.getElementById('clientNewAppForm');
|
||||
|
||||
myForm.addEventListener('submit', function(e) {
|
||||
// 2. Stop the page reload
|
||||
e.preventDefault();
|
||||
|
||||
// 3. Extract data from the form
|
||||
const formData = new FormData(this);
|
||||
const formAction = $(this).attr("action");
|
||||
// Convert to JSON if your API requires it (common for modern backends)
|
||||
const data = Object.fromEntries(formData.entries());
|
||||
|
||||
// 4. Execute the AJAX (Fetch) request
|
||||
fetch(formAction, {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json', // Inform server of JSON content
|
||||
'Accept': 'application/json' // Expect JSON response
|
||||
'Content-Type': 'application/json',
|
||||
'Accept': 'application/json'
|
||||
},
|
||||
body: JSON.stringify(data)
|
||||
})
|
||||
.then(response => response.json())
|
||||
.then(result => {
|
||||
console.log('Success:', result);
|
||||
// 5. Optional: Close modal or show success message
|
||||
alert('Data submitted successfully!');
|
||||
// $.alert('Data submitted successfully!');
|
||||
Swal.fire({
|
||||
title: "Sucess",
|
||||
text: "New App successfully created",
|
||||
icon: "success"
|
||||
});
|
||||
this.reset();
|
||||
setTimeout(() => { location.reload(); }, 2000);
|
||||
})
|
||||
.catch(error => {
|
||||
console.error('Error:', error);
|
||||
|
||||
Reference in New Issue
Block a user