Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New Coder
    Join Date
    Apr 2011
    Posts
    92
    Thanks
    26
    Thanked 0 Times in 0 Posts

    Replacing an include_once message with JQuery Modal Popup

    Hello, currently throughout my entire site, I am using a basic, include_once in the php, to redirect the user to another page (msgToUser.php), and display the desired message: For example on my profile page I have several instances of the following, whereby the $msgToUser variable may be different depending on certain things:

    Code:
    $msgToUser = "You and $firstname are NOT friends, but a friend request was sent on $request_time <br />";
    include_once('msgToUser.php');
    exit();
    Or on an another page (activation.php) I may have:

    Code:
    if ($doublecheck > 0) { 
        $msgToUser = "Your account has been activated! <br /><br />
         You may now login.";
        include 'msgToUser.php'; 
        exit();
    }
    What I want to be able to do, is replace all of these redirects with a simple jquery popup, particularly the Jquery Modal Dialog confirmation box (in case I want to include a link in the popup). I already have the jquery library on my site, along with the jquery-ui and jquery-css. Is there a simple way to do this by adding a little script to either the initial page or to the msgToUser.php page? I am sort of new to using Jquery... Also would it be wise to keep the msgToUser.php page in place (somehow in conjunction with the jquery popup), in case someone does not have a js/jquery enabled browser?

  • #2
    Senior Coder DanInMa's Avatar
    Join Date
    Nov 2010
    Location
    Salem,Ma
    Posts
    1,577
    Thanks
    13
    Thanked 248 Times in 248 Posts
    you could use a hidden div to load the data in, then use the dialog function something like so:

    function usermsg(datadivid,remotefileurl){
    $( "#"+datadivid ).load(remotefileurl,function(){
    $( "#"+datadivid ).dialog({
    modal: true,
    buttons: {
    Ok: function() {
    $( this ).dialog( "close" );
    }
    }
    });
    });
    }

    then I believe you can echo it from php

    echo"<script>usermsg('mesgdiv','msgToUser.php')</script>

  • #3
    New Coder
    Join Date
    Apr 2011
    Posts
    92
    Thanks
    26
    Thanked 0 Times in 0 Posts
    Thanks for your suggestion... but now I am actually considering another way. To give you an idea:

    So whenever you click on someone's picture for example, it takes you to: http://localhost/MySite/profile.php?id=110

    So there is a check to see if that member is your friend or not. And if I click on a member who is not (yet) my friend, I want to send him to msgToUser.php (which has it's own html) and echo something like "You and $thismember are not yet friends, Click Here to Send A Friend Request"... And then there is the "exit()" So I can exit the page, before that member's profile is run... Because if they are not yet friends, I don't want to be able to view the other guy's profile.

    Now that I think about it, I may be better off just disregarding msgToUser.php and just having a jquery pop-up display the message....

    Or.... is there a way to just make $msgToUser.php come up as sort of like a smaller sized pop-up window, on top of the current window (without proceeding to profile.php)? That way I could just stay on the same page, and just have the pop-up come up. I just want a simple way to be able to send a message to the user, with the option to have him take further action.


  •  

    Tags for this Thread

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •