Lost Password?

Go Back   CodeCall Programming Forum > Web Development Forum > AJAX

AJAX Web based language that allows asynchronous loading of pages that does not interfere with normal page loading.

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 09-03-2007, 09:59 AM
archive02 archive02 is offline
Newbie
 
Join Date: Nov 2006
Posts: 10
Rep Power: 0
archive02 is on a distinguished road
Default Updating a counter with AJAX

The counter at the bottom of my website needs to be updated dynamically using the count() from MySQL and PHP. Now, how do I update this on the page without the user having to reload? I'm a bit confused on how to have JavaScript execute PHP code without forwarding the user to the new page.

Anyone know how this is done?
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote

Sponsored Links
  #2 (permalink)  
Old 11-03-2007, 10:24 PM
fahlyn's Avatar   
fahlyn fahlyn is offline
Learning Programmer
 
Join Date: Nov 2007
Age: 25
Posts: 35
Rep Power: 3
fahlyn is on a distinguished road
Send a message via ICQ to fahlyn Send a message via AIM to fahlyn Send a message via MSN to fahlyn Send a message via Yahoo to fahlyn
Default

Quote:
Originally Posted by archive02 View Post
The counter at the bottom of my website needs to be updated dynamically using the count() from MySQL and PHP. Now, how do I update this on the page without the user having to reload? I'm a bit confused on how to have JavaScript execute PHP code without forwarding the user to the new page.

Anyone know how this is done?
What you'll need to do is probably setup a php script that will retrieve your count() and echo it. Then what you could do is have a JavaScript counter call that php script every 5 seconds (for example). Using AJAX you will be able to retrieve the value echoed from your php script in a JavaScript variable. I strongly recommend using prototype.js for ajax, it really takes care of handling all of the ugly XMLHTTPRequest stuff. It sounds like, if you're only going to be retrieving a counter you may want to use JSON...that way you will not have to parse XML in your JavaScript.

I know all of that is at a pretty high level, but I'm not sure where you're at as far as familiarity with JavaScript and AJAX. Let me know if you need more detail, I'd be glad to elaborate and post some code examples.

Happy Coding!
-Fahlyn
__________________
Visit My Google Group Here: Web Development Innovation
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
Considering Ajax, Part 1: Cut through the hype Ronin JavaScript and CSS 0 12-13-2006 02:36 PM
Myth-Busting AJAX (In)security Jordan AJAX 1 12-03-2006 01:21 PM
AJAX Evolved Jordan JavaScript and CSS 0 09-09-2006 01:12 PM
More AJAX Resources NeedHelp JavaScript and CSS 2 07-13-2006 12:57 PM
Anybody use Ajax? Dan JavaScript and CSS 9 07-05-2006 03:25 PM


All times are GMT -5. The time now is 06:22 PM.

Contest Stats

dargueta ........ 128.00000
John ........ 127.00000
Xav ........ 107.00000
gaylo565 ........ 18.00000
Johnnyboy ........ 3.00000
navghost ........ 1.00000

Contest Rules

Ads