Jump to content

Looking for AJAX/jQuery solution with PHP/CI


nydeveloper

Recommended Posts

I'm running PHP with CodeIgniter and have completed some functions, run every x minutes by cron jobs, that update specific data values in my local DB.

 

The next step of my project is to display these values on my home page, which is simple enough. However, what I'd like to do is display this data in a way that it will auto update every x seconds if that data value has changed in my DB. My assumption is the best way to do this will be via jQuery/AJAX, but this is where I'm stuck. I've done some research and believe that I have jQuery properly enabled in my CI installation, but I'm not clear on the next step. The majority of examples that I've found on the Web deal with handling form data, radio button selections, menu selections, etc without the need for a refresh, button press, page submission, etc. However, I can't seem to find any help on what I'm trying to achieve - which seems fairly straight forward.

 

I realize that this is a PHP forum, and not specific to the CI framework, but the community here seems extremely knowledgable and willing to help out so I figured I'd give it a try first.

 

Any guidance here is appreciated. Thanks in advance for your time.

Link to comment
Share on other sites

  • 4 weeks later...

 Greetings nydeveloper,

 

 I think I understand what you're asking for, you would like the data on your page to update at set intervals to reflect the updates performed by your cron jobs? You could use jQuery to do a refresh on the div every x seconds to achieve the result your looking for.

 

This will show you about setInterval() which is what I'm talking about, and I would use this in my success area after polling the server for the new data.

 

http://www.w3schools.com/jsref/met_win_setinterval.asp

 

I hope this helps you out (:

 

-Gaddam

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.