I am using jQuery to submit a form, which calls another.php, then I use jQuery-UI for a pop-up message, but it is not showing.
Without post, if I give the parameters as variables it will show the popup message.
This is the jQuery:
<script>
$(document).ready(function() {
$("#divhide").hide();
$('#info').submit(function() {
$.post('another.php',$('#info').serialize(), function() {
location.reload(true);
});
return false;
});
</script>
And this is the code in another.php:
<link rel="stylesheet" href="assets/jquery-ui.css">
<script src="assets/jquery.min.js"></script>
<script src="assets/jquery-ui.js"></script>
<script>
$(function() {
$("#dialog").dialog({
width: 200,
hide: 'slide',
position: 'top',
show: 'slide',
close: function(event, ui) {
window.location.href = history.back();
}
});
});
</script>
<div id="dialog" title="Error">
<p><?php echo "Error : Already X has the value $X"; ?></p>
</div>
$.ajax()call<div id="dialog"from the DOM), include that in your main page and then just call the function when you want to show a dialog. AJAX is completely the wrong tool for the task of showing a popup. If another.php does actually also process the form data, then please keep it, but move the task of showing the popup into the "success" of your AJAX call.successyou can open the dialog. Onfaildo something else. That is the logical way of doing it.