js is referenced in the code
<!-- Prompt message start-->
<script src="<%=basePath%>static/javascripts/sweetalert-dev.js" type="text/javascript"></script>
<!-- prompt message end-->
Code example in the actual project:
//delete function delRow(id){ swal({ title: "Are you sure you want to delete?", text: "Are you sure you want to delete this data?", type: "warning", showCancelButton: true, closeOnConfirm: false, animation: "slide-from-top", cancelButtonText: "Cancel", confirmButtonText: "Yes, I want to delete", confirmButtonColor: "#ec6c62" }, function() { ajax.callhz( "${pageContext.request.contextPath}/user/del", {Id: id}, function(datas, status){ if(datas.errorCode ==0){//Success if(datas.data.length >0){ var count = datas.data[0].count; // swal("Successful operation!", "Deleted successfully: "+count+" pieces of data!", "success"); swal({ title: "Operation successful!", text: "Deleted successfully: "+count+" pieces of data!", animation: "slide-from-top", type: "success", html: true, timer: 3000 }); } }else{ swal("warning", "Delete operation failed!", "error"); } }, function( textStatus, errorThrown){}); }); }
swal API method
parameter | describe | Defaults |
title | Tooltip title | - |
text | Tips | - |
type | Prompt type, there are: success (success), error (error), warning (warning), input (input). | - |
showCancelButton | Whether to show the "Cancel" button. Set Chinese name: cancelButtonText: "Cancel", | - |
animation | The animation effect when the prompt box pops up, such as slide-from-top (slide down from the top), etc. | - |
html | Whether to support html content. | - |
timer | Set the time (milliseconds) to automatically close the prompt box. | - |
showConfirmButton | Whether to display the OK button. | - |
confirmButtonText | Defines the text content of the OK button. | - |
imageUrl | Define the image address in the popup box. |
Need to leave a message to communicate