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

Member Avatar for diafol

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.

Lol, says I have to wait 40 minutes to download your file, no thanks.

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

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');
			}
		}
		
	});

}
Member Avatar for diafol

$('#pageContent').php()

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

Please download the file http://bit.ly/hYjWNL so you can see the issue. only 30KB

Member Avatar for diafol

No thank you, no downloads. Good luck.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.