JJ Beck
JJ Beck

Reputation: 5283

Connecting Chrome extension to server

I know that Google Chrome extension can have some HTML and JavaScript. But I would like to connect it to my server. When the user clicks a button on the extension when he's navigating a certain URL, the URL is added to the database on the server. Is it possible to implement this functionality?

Upvotes: 2

Views: 5179

Answers (1)

mrtsherman
mrtsherman

Reputation: 39872

Yes it is possible. Just add event handlers for when urls are clicked. You can then send the data back to your server asynchronously. Hopefully you are informing your plugin customers that you intend to track all their clicks.

I would recommend using a library like jQuery for this.

//bind to all links
$('a').click( function() {
   //get the url
   var url = $(this).prop('href');
   //send the url to your server
   $.ajax({
        type: "POST",
        url: "http://yourserver.com/process.php",
        data: "url=" + url
   });
});

You will need a server side language like php or asp to parse the posted url and store it in your database.

Upvotes: 3

Related Questions