0

Hello I am currently working on a project but I am currently stuck, what I'm trying to do is add a simple PHP site hit counter to an ajax site which counts the # of visits to an specific page, now I gotten the pages to show up and they are .php but the values lets say 10 which is the # of visits to that page will not show up, please help me, if you need any further information please let me know. I attached the files so you can play with it, don't forget to upload it to your host, the ajax site will now work locally.

Download: http://bit.ly/gMcdBO

Edited by luisthedude: n/a

4
Contributors
7
Replies
8
Views
6 Years
Discussion Span
Last Post by diafol
0

Ho ho. Me no downloady. Just print your code here.

I can't understand the problem - this must be one of the longest sentences DW has had!

>values lets say 10 which is the # of visits to that page will not show up

I assume that this is the key part?Like I said, show your code.

0

ok so if the number is xyz [eg: 123] recursively add the img elements corresponding to each digit from the right till the number reduces to 0.

from what you posted it seems you can do 0 to 9 ut ur stuck at 10

0

I have re-upload the file here http://bit.ly/hYjWNL, The problem is not with the PHP counter its really the ajax site because the PHP Hit Counter will show up If I added to a blank .php file but If its implemented into the ajax site than the php is not been called. I have check this whith firebug.


jQuery script

var default_content="";

$(document).ready(function(){
	
	checkURL();
	$('ul li a').click(function (e){

			checkURL(this.hash);

	});
	
	//filling in the default content
	default_content = $('#pageContent').php();
	
	
	setInterval("checkURL()",250);
	
});

var lasturl="";

function checkURL(hash)
{
	if(!hash) hash=window.location.hash;
	
	if(hash != lasturl)
	{
		lasturl=hash;
		
		// FIX - if we've used the history buttons to return to the homepage,
		// fill the pageContent with the default_content
		
		if(hash=="")
		$('#pageContent').php(default_content);
		
		else
		loadPage(hash);
	}
}


function loadPage(url)
{
	url=url.replace('#page','');
	
	$('#loading').css('visibility','visible');
	
	$.ajax({
		type: "POST",
		url: "load_page.php",
		data: 'page='+url,
		dataType: "php",
		success: function(msg){
			
			if(parseInt(msg)!=0)
			{
				$('#pageContent').html(msg);
				$('#loading').css('visibility','hidden');
			}
		}
		
	});

}

Edited by luisthedude: n/a

0

$('#pageContent').php()

What does this do? I've never seen the .php method/property in jQuery.

0

No thank you, no downloads. Good luck.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.