I have ajax code that works correctly and gives the desired result. I want to change this code and want the popup / modal field to be open when receiving a response from ajax.
I can open a popup / modal window with the click of a button
<button class="btn btn-primary" data-toggle="modal" data-target="#bsModal3">
Small Modal
</button>
<div class="modal fade" id="bsModal3" tabindex="-1" role="dialog" aria-labelledby="mySmallModalLabel" aria-hidden="true">
<div class="modal-dialog modal-sm">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
<h4 class="modal-title" id="mySmallModalLabel">Modal title</h4>
</div>
<div class="modal-body">
Your content goes here...
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
<button type="button" class="btn btn-primary">Save changes</button>
</div>
</div>
</div>
</div>
but don't know how to open it automatically in ajax.
here is my ajax code
$.ajax({
type: 'post',
url: 'test2.php',
dataType: 'json',
data: {
txt: txtbox,
hidden: hiddenTxt
},
cache: false,
success: function (returndata) {
if (returndata[4] === 1) {
} else {
}
},
error: function () {
console.error('Failed to process ajax !');
}
});
can anyone tell me how to do this
source
share