Help me tackle this!

Discussion in 'JavaScript' started by absentx, May 13, 2010.

  1. #1
    Okay so I just need some help as I try and tackle one of the final pieces to a site I am building.

    I have an inbox feature for members that they can access when they are logged in. How I have it right now is that when the user clicks inbox, a modal dialog box opens and displays the messages in their inbox. Now, I am not real good at this yet so I am trying to figure out where to go next:

    1. I want the user to be able to click on a message and then simply have that message display in the same dialog box.

    2. I then want the user to be able to return to their main inbox and basically do everything they need in the same modal dialog box.

    Is this something where I will use XMLHttpRequest object to communicate with the server and grab the messages from the database for display or are there other options?

    I am just looking for someone to help me come up with a game plan that I can then research and execute.

    Thanks!
     
    absentx, May 13, 2010 IP
  2. JiveturkeyJay

    JiveturkeyJay Peon

    Messages:
    3
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Hello

    What are you building your site in PHP etc, I guess you must have some database to log the users etc.
    First I'd build the application to work without Javascript so you have a fall back option, after that it should be easy to use the same script to build your Ajax request. Basically if the user has javascript enabled you'd prevent the default action on the link and call the script via the XMLHttpRequest object as you've described.

    Jay
     
    JiveturkeyJay, May 13, 2010 IP
  3. absentx

    absentx Peon

    Messages:
    98
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Correct, most of the site is php with a mysql database.

    So my plan so far, which is working quite nicely is like this:

    
    <script type="text/javascript" src="myajaxstuff.js"></script>
    </head>
    <body>
    	
        	<a id="makeMessageRequest" href="messagetest.php?PASS MY MESSAGE VARIABLES HERE">Message you want to read</a></p>
    
    
    Code (markup):
    Now, in terms of building a base option for users without javascript...I suppose I could structure some php if statements to see if javascript was enabled, and if so...run neato ajax style messenger system....if not, run regular message system?
     
    absentx, May 13, 2010 IP
  4. JiveturkeyJay

    JiveturkeyJay Peon

    Messages:
    3
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #4
    You should not need to check if Javascript is enabled, its a pain to do. Basically you would use javascript to prevent the default action of the anchor, ie you'd stop the link working, and process the Ajax request instead. You'd need a listener to detect the click and a callback to deal with the Ajax request. You'd use the url string to pass the variables as normal.

    Are you using a javascript library or doing it by hand?

    J
     
    JiveturkeyJay, May 13, 2010 IP
  5. absentx

    absentx Peon

    Messages:
    98
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #5
    Yeah I have Jquery on the site right now. Not doing it by hand, simply not that good at it yet.
     
    absentx, May 13, 2010 IP