Turn on suggestions
Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.
Showing results for
DIY hit counter with/without AJAX
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Plusnet Community
- :
- Forum
- :
- Help with my Plusnet services
- :
- Everything else
- :
- DIY hit counter with/without AJAX
DIY hit counter with/without AJAX
23-03-2008 1:05 PM
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Report to Moderator
I need to embed a Home page’s hit count in the text of another page – not as a graphic (neither an off-the-peg counter such as PN's nor one of my own) but as simple HTML text numbers (with the running count held in an SQL database updated by a few lines of PHP).
Since PN uses separate servers for ‘normal webspace’ and CGI, and since for performance reasons I want the Home page to be served from the home pages server, I am going round in circles trying to find an elegant way to do this.
I intended to use ‘onload’ XMLHttpRequests (i.e. AJAX calls) from the Home page and count-display page, but quickly realised that the one from the Home page (at least) would fail because the call will be to the CGI server which is not the Home page’s server, and such cross-site AJAX calls are blocked (with the possible exception of Google's own APIs!)
I was left with the usual hit-counter trick of loading a <img> from a page with a script attached (e.g. img src="http://domain_name.com/php_script_name?page_name "). This could be told to update the count if ‘page_name’ was the home page name, and the returning graphic could then be non-displaying and ignored. But I would still appear to need to serve from the CGI server the page which will actually display the count.
DAK a simple way to serve both the Home page and the display page from the home pages server or a more elegant way to do what I want pls?
Since PN uses separate servers for ‘normal webspace’ and CGI, and since for performance reasons I want the Home page to be served from the home pages server, I am going round in circles trying to find an elegant way to do this.
I intended to use ‘onload’ XMLHttpRequests (i.e. AJAX calls) from the Home page and count-display page, but quickly realised that the one from the Home page (at least) would fail because the call will be to the CGI server which is not the Home page’s server, and such cross-site AJAX calls are blocked (with the possible exception of Google's own APIs!)
I was left with the usual hit-counter trick of loading a <img> from a page with a script attached (e.g. img src="http://domain_name.com/php_script_name?page_name "). This could be told to update the count if ‘page_name’ was the home page name, and the returning graphic could then be non-displaying and ignored. But I would still appear to need to serve from the CGI server the page which will actually display the count.
DAK a simple way to serve both the Home page and the display page from the home pages server or a more elegant way to do what I want pls?
Zen from May 17. PN Business account from 2004 - 2017
Message 1 of 2
(1,284 Views)
1 REPLY 1
Re: DIY hit counter with/without AJAX
23-03-2008 2:11 PM
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Report to Moderator
Have a look at www.hotscripts.com there are text and graphical counter scripts in all the main scripting languages. You should be able to find what you are looking for there.
Message 2 of 2
(318 Views)
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Plusnet Community
- :
- Forum
- :
- Help with my Plusnet services
- :
- Everything else
- :
- DIY hit counter with/without AJAX