Go Back   CodingForums.com > :: Client side development > JavaScript programming > JavaScript frameworks

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 12-16-2011, 09:29 PM   PM User | #1
Juniper747
New Coder

 
Join Date: Apr 2011
Posts: 92
Thanks: 26
Thanked 0 Times in 0 Posts
Juniper747 is an unknown quantity at this point
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?
Juniper747 is offline   Reply With Quote
Old 12-17-2011, 02:08 AM   PM User | #2
DanInMa
Senior Coder

 
DanInMa's Avatar
 
Join Date: Nov 2010
Location: Salem,Ma
Posts: 1,307
Thanks: 12
Thanked 204 Times in 204 Posts
DanInMa is on a distinguished road
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>
__________________
- Firebug is a web developers best friend! - Learn it, Love it, use it!
- Validate your code! - JQ/JS troubleshooting
- Using jQuery with Other Libraries - Jslint for Jquery/other JS library users
DanInMa is offline   Reply With Quote
Old 12-18-2011, 08:06 PM   PM User | #3
Juniper747
New Coder

 
Join Date: Apr 2011
Posts: 92
Thanks: 26
Thanked 0 Times in 0 Posts
Juniper747 is an unknown quantity at this point
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.
Juniper747 is offline   Reply With Quote
Reply

Bookmarks

Tags
jquery popup modal dialog

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 03:20 AM.


Advertisement
Log in to turn off these ads.