Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New to the CF scene
    Join Date
    Dec 2010
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Simple Click Tracking

    This is what I'm trying to do..

    I have an HTML file example

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

    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>


    <script>

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

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

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


    }
    });

    });

    </script>

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

  • #2
    Senior Coder Spudhead's Avatar
    Join Date
    Jun 2002
    Location
    London, UK
    Posts
    1,856
    Thanks
    8
    Thanked 110 Times in 109 Posts
    What does Firebug say? Can you see the AJAX call being made in the console to the PHP page in question?


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •