Inoive add update delete messages shown properly

This commit is contained in:
Swapnil9693
2026-03-24 15:51:55 +05:30
parent b78526ad9f
commit 14e799a1d4
4 changed files with 696 additions and 318 deletions

View File

@@ -7,6 +7,7 @@
<title>Edit Invoice</title>
<link rel="stylesheet" type="text/css" href="{{ url_for('static', filename='css/invoice.css') }}">
<link rel="stylesheet" type="text/css" href="{{ url_for('static', filename='css/style1.css') }}">
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
</head>
@@ -62,7 +63,7 @@
<div class="row2">
<div>
<label for="invoice_no">Invoice No:</label>
<input type="text" id="invoice_no" name="invoice_no" value="{{ invoice.Invoice_No }}" required/>
<input type="text" id="invoice_no" name="invoice_no" value="{{ invoice.invoice_no }}" required/>
</div>
<div>
<label for="invoice_date">Invoice Date:</label>
@@ -180,27 +181,29 @@ $(document).ready(function() {
$(this).closest(".hold-amount-row").remove();
});
// Submit form via AJAX
$("#invoiceForm").submit(function(e) {
e.preventDefault();
// Submit form via AJAX
$("#invoiceForm").submit(function(e) {
e.preventDefault();
$.ajax({
type: "POST",
url: $(this).attr("action"),
data: $(this).serialize(),
success: function(response) {
if(response.status === "success") {
$("#invoiceSuccessAlert").fadeIn().delay(3000).fadeOut();
$.ajax({
type: "POST",
url: $(this).attr("action"),
data: $(this).serialize(),
dataType: 'json', // ensure JSON is returned
success: function(response) {
if(response.status === "success") {
alert("Invoice updated successfully!"); // <-- Popup alert
}
},
error: function(xhr) {
alert("Error: " + xhr.responseJSON.message);
// ✅ Redirect to Add Invoice page (table part visible)
window.location.href = "{{ url_for('invoice.add_invoice') }}#addTable";
}
});
},
error: function(xhr) {
alert("Error: " + xhr.responseJSON?.message || "Something went wrong!");
}
});
});
});
</script>
</body>