• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Combining jQuery and PHP for a simple alert Box?


I want to show an simple jquery alert box within a simple if statement in php:

if($result == 0)
            #-- ----------------------------------------------------------------------------
            #   Kein zugehöriges Protokoll vorhanden
            #-- ----------------------------------------------------------------------------

                $("a").click(function() {
                alert("Hello world!");



            some other code

what I want. As the user you click on a href which leads to this view above. Now if there is nothing to show I want to display a popup alert window to notify the user that there is no entry at the moment present.

Am I on the right path?

Greetings Sebastian

Ok figured it out. I now got my alert by simply removing the click function handler.


It would be great if the user clicks ok in the alert box that he is automatically redirected to another page. Is that possible?

[eluser]Pascal Kriete[/eluser]
An alert blocks script execution, so right after the alert, add:
window . location = "http://www.gohere.com"; // remove the spaces

I will say though, that I despise random javascript alerts like this. So from a usability point of view, I would go a different route.

Thanks. Is it possible that the user is redirected to the previous page automatically?

The problem is that I "call" to this function from different locations in our app.

Can´t find anything.:-(

Got it, sorry.


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  

  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2020 MyBB Group.