My method of submitting a form involves using ajax, with the following code to confirm the submission and display a message on the same page within HTML:
$.ajax({
type: "POST",
url: "process.php",
data: {input1:class1b,input2:class2b},
dataType: "JSON",
success:
function(data) {
$("#message").html(data);
$("#message").addClass(" alert-info ");
},
error: function(err) {
$("#message").html(err);
$("#message").addClass(" alert-danger");
}
});
To show an alert message instead of displaying it in HTML, I use the following code:
$.ajax({
type: "POST",
url: "process.php",
data: {input1:class1b,input2:class2b},
dataType: "JSON",
success:
function(data) {
alert(data);
},
error: function(err) {
alert(err);
}
});
Although both codes work fine, I now want to use a different type of alert using this code:
$("#message").modal({backdrop: "static"});
I initially tried adding this code at the top:
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal">×</button>
<h4 class="modal-title">Alert</h4>
</div>
<div class="modal-body">
<p>Message.</p>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
</div>
</div>
However, I'm unsure where to add this code within the ajax code, or how to properly use it to display the received alert message.
$("#message").modal({backdrop: "static"});