Hello I have this HTML code:
<div class="col-md-6"> <div> <input type="number" id="items_percentage" value="<?php echo $task->task_item_percentage; ?>" maxlength="100" placeholder="Enter Percentage value" style="width: 160px;text-align: center;"> <div><small><b>(Please Enter Value Without Percentage %)</b></small></div> </div> <div> <h3>Or</h3> </div> <div> <input type="number" id="task_item_manual_total_price" value="<?php echo $task->task_item_manual_total_price; ?>" placeholder="Enter Total Price" style="width: 160px;text-align: center;"> </div> <div style="margin-top: 20px;"> <a href="javascript:;" id="saveItemsPercentageBtn" class="btn btn-primary">Save</a> </div> <br> </div>
And the javaScript code:
$(document).on("click","#saveItemsPercentageBtn", function(){ var didConfirm = confirm("Do you want to save total percentage price ? "); if (didConfirm === true) { var taskid = '<?php echo $task->id; ?>'; var task_item_percentage = $("#items_percentage").val(); var task_item_manual_total_price = $("#task_item_manual_total_price").val(); if(taskid && task_item_percentage && task_item_percentage != ""){ $.ajax({ type: "POST", url: admin_url+"tasks/update_task_item_percentage", data: {id:taskid,task_item_percentage:task_item_percentage}, success: function(data) { alert("Successfully updated percentag price...!"); window.location.reload(); } }); } if(taskid && task_item_manual_total_price && task_item_manual_total_price != ""){ $.ajax({ type: "POST", url: admin_url+"tasks/update_task_item_manual_total_price", data: {id:taskid,task_item_manual_total_price:task_item_manual_total_price}, success: function(data) { alert("Successfully updated total price...!"); window.location.reload(); } }); } } //$(document).off("ajaxSuccess") });
My question is how can I eliminate the confirmation messages? I want my inputs to be save without reloading and without confirming! Can someone help me please? If you will need more details i will tell you all you need! Thanks
Advertisement
Answer
For removes confirmation messages
var didConfirm = confirm("Do you want to save total percentage price ? "); if (didConfirm === true) {
and the last close bracket of if conditional ‘ } ‘
Success is getting the response of the request if you remove that, the alert and reload will dissapear
success: function(data) { alert("Successfully updated percentag price...!"); window.location.reload(); }