Call to undefined function alert():

3,982 views
Skip to first unread message

rahhal mahassen

unread,
Dec 11, 2010, 8:28:19 AM12/11/10
to joomla-de...@googlegroups.com
I'm using joomla 1.5.22
i try to show the alert message with "if condition then action else alert('message')but i can't see the alert message : I see only this error (Call to undefined function alert())
my code is:
if ..... then {return.....}
else {
alert ('Vous n'.'êtes pas autorisé a voir cette page, veuillez vous inscrire, merci.');}
I tried to replace the alert message with "return JText::_('Vous n'.'êtes pas autorisé a voir cette page, veuillez vous inscrire, merci.');" and it's ok :the text is done.
I want to see the alert message:window with the alert message or open a new window(pop-up)with a link
what shall i do to solve this problem?
Please i need help to retrieve a solution

Best regards

Sam Moffatt

unread,
Dec 11, 2010, 9:04:58 AM12/11/10
to joomla-de...@googlegroups.com
I have a distinct feeling you're trying to mix Javascript's "alert"
function with PHP which is why the JText works fine and why you get an
undefined function error from PHP when you try to feed it Javascript.

I have a distinct feeling you're doing something for the wrong
reasons. Can you elaborate on what you're trying to achieve and why
you're trying to achieve it using this method? Some context might help
provide solutions (and a larger chunk of source code).

Cheers,

Sam Moffatt
http://pasamio.id.au

> --
> You received this message because you are subscribed to the Google Groups
> "Joomla! General Development" group.
> To post to this group, send an email to joomla-de...@googlegroups.com.
> To unsubscribe from this group, send email to
> joomla-dev-gene...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/joomla-dev-general?hl=en-GB.
>

rahhal mahassen

unread,
Dec 11, 2010, 9:24:02 AM12/11/10
to joomla-de...@googlegroups.com
Thanks for your answer,
I'm trying to show the alert message or to open a new window(redirecting to the registration page).
I don't understand how to do it.
My essential object is to open a new window(pop-up)
Please help me to do this.

Best regards

2010/12/11 Sam Moffatt <pas...@gmail.com>
problem.png

anci wasim

unread,
Dec 11, 2010, 12:09:50 PM12/11/10
to joomla-de...@googlegroups.com
Hello, 

 You are trying to alert javascript box into PHP , thats wrong dude , If you want alert message eighter you call component url through ajax and get response and alert it like this.

I am showing you 2 methods.

javascript code :, I am using Jquery POST Ajax method, whatever you will send through component url will be alret into template page.
<script>
function call_server_url(){
   $.post("COMPONENT URL ",{PARAMETER},function(message){
    alert(message);
})
}
</script >

2.Second Method, you try this.
<?php 

function Your_Function_Name(){
   echo '<script>alert("'._JText("WHATEVER YOUR MESSAGE HERE").'")</script>';
}
Regards
 Shaikh Wasim (Software Engineer).

Sam Moffatt

unread,
Dec 11, 2010, 7:42:21 PM12/11/10
to joomla-de...@googlegroups.com
Normally you would set a redirect in the controller and in the
redirect set the message to be displayed to the user. There is no
point putting up a popup window where you intend to redirect them
after they've downloaded half the page, just redirect the user.

Check out JController::setRedirect or JApplication::redirect for more
details. The pattern is used in unauthorised situations with a
redirect back for login however in your case you're just going to
redirect to a sign up page.

Cheers,

Sam Moffatt
http://pasamio.id.au

rahhal mahassen

unread,
Dec 12, 2010, 1:50:02 AM12/12/10
to joomla-de...@googlegroups.com
I tried to do so:
......
else {
            jimport( 'joomla.application.component.controller' );

            $this->Redirect('index.php?option=com_user&view=login', 'Veuillez vous identifier','notice');
            return $this;}
But i saw again this error:
Fatal error: Call to undefined method ElementVideo::Redirect() in C:\wamp\www\Societe\administrator\components\com_zoo\elements\video\video.php on line 124
what shall i do to solve this problem?

2010/12/12 Sam Moffatt <pas...@gmail.com>

Sam Moffatt

unread,
Dec 12, 2010, 2:51:54 AM12/12/10
to joomla-de...@googlegroups.com
You're in a subclass of something in Zoo it seems, I'd suggest asking
the zoo people what the best course of action would be.

Cheers,

Sam Moffatt
http://pasamio.id.au

On Sun, Dec 12, 2010 at 4:50 PM, rahhal mahassen

Reply all
Reply to author
Forward
0 new messages