-1

I want to show a message box when data is already inserted in to MySQl table. My code is as below :

 if($insert_query)
    {  
    <script type='text/javascript'> 
    $.msgBox('Data Added');
    window.location = 'bentry.php'; 
    </script> 
    }

But alert is not shown. How to solve this problem.

3 Answers3

1

Try this :

echo "<script type='text/javascript'> 
    $.msgBox('Data Added');
    window.location = 'bentry.php'; 
    </script> "

OR

if($insert_query)
    {  ?>
    <script type='text/javascript'> 
    $.msgBox('Data Added');
    window.location = 'bentry.php'; 
    </script> 
  <?php  } ?>
Engineer
  • 5,911
  • 4
  • 31
  • 58
  • Your second option is my original code , which is not working.. Problem is the demo example given in Jquery.msBOx it shows the msgbox when someone clicked but I want it to be shown when some condition is true. – Jayanta Kumar Nath Nov 11 '13 at 07:16
  • @JayantaKumarNath 1. No..You dont have closing/opening braces. That makes it diffrent. 2.Is the condition being true? Do a normal alert instead of msg box to check if the solution is working. If it works, then you have a probelm with msgbox library. – Engineer Nov 11 '13 at 07:19
  • when i use alert("Data Added"); its working but when tried to replace that with msgbox it does not work. So for the time being I put alert . But want to know what is the problem. – Jayanta Kumar Nath Nov 11 '13 at 07:22
  • @JayantaKumarNath Exactly what i thought. Have you included all libraries required for msgbox? Are you calling the function correctly? – Engineer Nov 11 '13 at 07:23
  • Yes I included all the libraries that neede... but I am sure that calling of the function is creating problem.... as when I added data .. the data got inserted into the table but no alert msgbox shows.. – Jayanta Kumar Nath Nov 11 '13 at 07:27
0

the reason is

 window.location = 'bentry.php'; 

$.msgBox('Data Added'); is loaded but redirection script naviagted into another page.

Krish R
  • 22,583
  • 7
  • 50
  • 59
-1
if($insert_query)
{  
<script type='text/javascript'> 
$.msgBox('Data Added');
setTimeout(function(){window.location = 'bentry.php';},1000); 
</script> 
}