|
|
|
@ -1378,73 +1378,81 @@ |
|
|
|
}); |
|
|
|
}); */ |
|
|
|
$(document).ready(function () { |
|
|
|
$('#submitButton').click(function (e) { |
|
|
|
e.preventDefault(); // Prevent the default form submission |
|
|
|
|
|
|
|
// Collect data from the form fields |
|
|
|
var complainantName = $('#summaryName').text().trim(); |
|
|
|
var complainantAddr = $('#summaryStreet').text().trim(); |
|
|
|
var mobileNo = $('#summaryMobile').text().trim(); |
|
|
|
var email = $('#summaryEmail').text().trim(); |
|
|
|
var complaintType = $('#summaryComplaintType').text().trim(); |
|
|
|
var complaintTitle = $('#summaryComplaintTitle').text().trim(); |
|
|
|
var complaintDetails = $('#summaryDescription').text().trim(); |
|
|
|
var streetId = $('#summaryStreetId').text().trim(); |
|
|
|
var landmark = $('#summaryLandmark').text().trim(); |
|
|
|
var latitude = $('#summaryLatitude').text().trim(); |
|
|
|
var longtitude = $('#summaryLongitude').text().trim(); // Note the misspelling: it should match the controller parameter |
|
|
|
var gender = $('#summaryGender').text().trim(); |
|
|
|
var imageSrc = $('#summaryImage').attr('src'); |
|
|
|
|
|
|
|
console.log({ |
|
|
|
ComplainantName: complainantName, |
|
|
|
ComplainantAddr: complainantAddr, |
|
|
|
MobileNo: mobileNo, |
|
|
|
Email: email, |
|
|
|
ComplaintType: complaintType, |
|
|
|
ComplaintTitle: complaintTitle, |
|
|
|
ComplaintDetails: complaintDetails, |
|
|
|
StreetId: streetId, |
|
|
|
Comp_Image: imageSrc, |
|
|
|
latitude: latitude, |
|
|
|
longtitude: longtitude, |
|
|
|
Landmark: landmark, |
|
|
|
gender: gender |
|
|
|
}); |
|
|
|
|
|
|
|
// AJAX call to your backend controller |
|
|
|
$.ajax({ |
|
|
|
url: '/register', // Update to your Spring Boot endpoint |
|
|
|
type: 'POST', |
|
|
|
data: { |
|
|
|
ComplainantName: complainantName, |
|
|
|
ComplainantAddr: complainantAddr, |
|
|
|
MobileNo: mobileNo, |
|
|
|
Email: email, |
|
|
|
ComplaintType: complaintType, |
|
|
|
ComplaintTitle: complaintTitle, |
|
|
|
ComplaintDetails: complaintDetails, |
|
|
|
StreetId: streetId, |
|
|
|
Comp_Image: imageSrc, |
|
|
|
latitude: latitude, |
|
|
|
longtitude: longtitude, // Ensure this matches the controller parameter name |
|
|
|
Landmark: landmark, |
|
|
|
gender: gender |
|
|
|
}, |
|
|
|
success: function (response) { |
|
|
|
// Handle success response |
|
|
|
console.log('Success:', response); |
|
|
|
alert('Complaint registered successfully!'); |
|
|
|
// You can also redirect or reset the form here |
|
|
|
}, |
|
|
|
error: function (xhr, status, error) { |
|
|
|
// Improved error handling |
|
|
|
console.log('Error:', xhr.responseText, status, error); |
|
|
|
alert('Error: ' + xhr.status + ' ' + xhr.statusText); |
|
|
|
} |
|
|
|
}); |
|
|
|
}); |
|
|
|
}); |
|
|
|
$('#submitButton').click(function (e) { |
|
|
|
e.preventDefault(); // Prevent the default form submission |
|
|
|
|
|
|
|
// Collect data from the form fields |
|
|
|
var complainantName = $('#summaryName').text().trim(); |
|
|
|
var complainantAddr = $('#summaryStreet').text().trim(); |
|
|
|
var mobileNo = $('#summaryMobile').text().trim(); |
|
|
|
var email = $('#summaryEmail').text().trim(); |
|
|
|
var complaintType = $('#summaryComplaintType').text().trim(); |
|
|
|
var complaintTitle = $('#summaryComplaintTitle').text().trim(); |
|
|
|
var complaintDetails = $('#summaryDescription').text().trim(); |
|
|
|
var streetId = $('#summaryStreetId').text().trim(); |
|
|
|
var landmark = $('#summaryLandmark').text().trim(); |
|
|
|
var latitude = $('#summaryLatitude').text().trim(); |
|
|
|
var longtitude = $('#summaryLongitude').text().trim(); // Note the misspelling |
|
|
|
var gender = $('#summaryGender').text().trim(); |
|
|
|
var imageSrc = $('#summaryImage').attr('src'); |
|
|
|
|
|
|
|
console.log({ |
|
|
|
ComplainantName: complainantName, |
|
|
|
ComplainantAddr: complainantAddr, |
|
|
|
MobileNo: mobileNo, |
|
|
|
Email: email, |
|
|
|
ComplaintType: complaintType, |
|
|
|
ComplaintTitle: complaintTitle, |
|
|
|
ComplaintDetails: complaintDetails, |
|
|
|
StreetId: streetId, |
|
|
|
Comp_Image: imageSrc, |
|
|
|
latitude: latitude, |
|
|
|
longtitude: longtitude, |
|
|
|
Landmark: landmark, |
|
|
|
gender: gender |
|
|
|
}); |
|
|
|
|
|
|
|
// AJAX call to your backend controller |
|
|
|
$.ajax({ |
|
|
|
url: '/register', // Update to your Spring Boot endpoint |
|
|
|
type: 'POST', |
|
|
|
data: { |
|
|
|
ComplainantName: complainantName, |
|
|
|
ComplainantAddr: complainantAddr, |
|
|
|
MobileNo: mobileNo, |
|
|
|
Email: email, |
|
|
|
ComplaintType: complaintType, |
|
|
|
ComplaintTitle: complaintTitle, |
|
|
|
ComplaintDetails: complaintDetails, |
|
|
|
StreetId: streetId, |
|
|
|
Comp_Image: imageSrc, |
|
|
|
latitude: latitude, |
|
|
|
longtitude: longtitude, |
|
|
|
Landmark: landmark, |
|
|
|
gender: gender |
|
|
|
}, |
|
|
|
success: function (response) { |
|
|
|
// SweetAlert upon success |
|
|
|
Swal.fire({ |
|
|
|
title: 'Success!', |
|
|
|
text: 'Your complaint has been submitted.', |
|
|
|
icon: 'success', |
|
|
|
confirmButtonText: 'OK' |
|
|
|
}).then((result) => { |
|
|
|
if (result.isConfirmed) { |
|
|
|
// Redirect to home.html after clicking 'OK' |
|
|
|
window.location.href = 'home'; |
|
|
|
} |
|
|
|
}); |
|
|
|
}, |
|
|
|
error: function (xhr, status, error) { |
|
|
|
// Improved error handling |
|
|
|
console.log('Error:', xhr.responseText, status, error); |
|
|
|
alert('Error: ' + xhr.status + ' ' + xhr.statusText); |
|
|
|
} |
|
|
|
}); |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
</script> |
|
|
|
|
|
|
|
|