Results 1 to 4 of 4

Thread: Refreshing posts of a forum via ajax?

  1. #1
    Join Date
    Feb 2012
    Posts
    33
    Thanks
    7
    Thanked 0 Times in 0 Posts

    Default Refreshing posts of a forum via ajax?

    Hi guys,

    How could I refresh all the posts of a forum every X seconds using AJAX so that the user doesn't have to reload the page?

    Cheers

  2. #2
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,164
    Thanks
    265
    Thanked 690 Times in 678 Posts

    Default

    In what sense?

    AJAX allows you to replace content on a page with new content from a server. That's the (relatively) easy part, or at least it's straightforward.

    But to do this you'll also need a serverside language (probably PHP?) that will load the posts themselves. Do you have this set up? What forum software are you using?

    If this is not your own design (a forum made from software you downloaded) then the best option would be to check for a plugin/add-on/extension/mod that allows you to do this. Maybe someone else has already done the work for you.

    If this is your own design, then you should be able to easily do the PHP part and you'll just need to plug in the AJAX for it.
    Daniel - Freelance Web Design | <?php?> | <html>| español | Deutsch | italiano | português | català | un peu de français | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum

  3. #3
    Join Date
    Feb 2012
    Posts
    33
    Thanks
    7
    Thanked 0 Times in 0 Posts

    Default

    Thanks for the reply

    I'm actually attempting to make a modification myself.

    The forum software is MyBB.

    Thanks

  4. #4
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,164
    Thanks
    265
    Thanked 690 Times in 678 Posts

    Default

    An AJAX setup requires two parts:

    1. An AJAX script (Javascript) that will replace part of the page with new content from a certain URL on the server.

    2. A PHP script that will generate the content when that URL is loaded. Note that this content should not be a full HTML page, but rather just the local HTML needed for that section of the page. For example, it might be <div>...</div> or <p>...</p>, but in almost all cases not <html>...</html>.

    There are many AJAX scripts around that you can use for part (1). The more specific part will be part (2). For that, you'll need to figure out how to deal with MyBB's post system. If MyBB has an API, that might be very helpful.

    Also, I'm still unclear about how you'd expect to refresh the posts without confusing the user, but if you can post more about that, maybe someone will have an idea.
    Daniel - Freelance Web Design | <?php?> | <html>| español | Deutsch | italiano | português | català | un peu de français | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum

Bookmarks

Posting Permissions

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