View Full Version : jQuery Simple Click Tracking

12-07-2010, 08:33 PM
This is what I'm trying to do..

I have an HTML file example

<a href="#1"> Test Click </a>
<a href="#2"> Test Click </a>

Nothing in the html file can be change..
What I want to do is track the clicks using jquery (ajax) and pass the url to php

The txt file would say something like
This link what clicked this many times but this ip address

I have some coding but can't get it to pass to php

This is what I have
<script src="http://code.jquery.com/jquery-1.4.4.js"></script>


$("a").live("click", function(){

var href = this.getAttribute('href');

type: "POST",
url: "stat.php",
data: "name=John&location=Boston",
success: function(msg){
alert( "Data Saved: " + href);




the data is not passing to php but can het the url to display in the alert box.

12-08-2010, 03:44 PM
What does Firebug (http://getfirebug.com/) say? Can you see the AJAX call being made in the console to the PHP page in question?