• Home
  • Categories
  • Recent
  • Popular
  • Top
  • Tags
  • Users
  • Groups
  • Documentation
    • Home
    • Read API
    • Write API
    • Plugin Development
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
v3.5.2 Latest
Buy Hosting

[Widget]Realtime topic updates

Scheduled Pinned Locked Moved Plugin Development
4 Posts 2 Posters 1.6k Views
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • N Offline
    N Offline
    Nisthar Gamers
    wrote on last edited by
    #1

    I need to know if there is an client side ajax method that i can use to poll for latest topics from selected categories. if there isn't, please suggest an alternative approach.

    1 Reply Last reply
    0
  • yariplusY Offline
    yariplusY Offline
    yariplus Community Rep
    wrote on last edited by yariplus
    #2

    You can get the data from any route by adding /api to the front of the route.

    $.getJSON('/api/category/1', function (data) {
        console.log(data.topics);
    });
    

    Will return up to the 20 most recent topics. The same that the user would see if they were viewing the page for category 1.

    1 Reply Last reply
    0
  • N Offline
    N Offline
    Nisthar Gamers
    wrote on last edited by
    #3

    @yariplus said:

    $.getJSON('/api/category/1', function (data) {
    console.log(data.topics);
    });

    I think i got this as a response for the request: "/category/1/announcements"

    Don't know if i am doing it wrong. I created a new html widget and added your script inside a script tag. In the console, I am not getting anything. But i can see the request is successful, but there is no console.log outputting. In the network tab, i can see the response for this request as : "/category/1/announcements"

    Sorry for the bad english

    1 Reply Last reply
    0
  • N Offline
    N Offline
    Nisthar Gamers
    wrote on last edited by
    #4

    Anyway, I get all the categories and topics using this route: /api/categories

    I think there is details on all topics also.

    1 Reply Last reply
    0

Copyright © 2023 NodeBB | Contributors
  • Login

  • Don't have an account? Register

  • Login or register to search.
Powered by NodeBB Contributors
  • First post
    Last post
0
  • Home
  • Categories
  • Recent
  • Popular
  • Top
  • Tags
  • Users
  • Groups
  • Documentation
    • Home
    • Read API
    • Write API
    • Plugin Development