🔔 Alert..!! Get 2 Month Free Cloud Hosting With $200 Bonus From Digital Ocean ACTIVATE DEAL

Just another lightweight jQuery plugin used to shorten long URL using Bit.ly URL shortening service.

URL URL-Shortener

Documentation

#Bitlr

A simple, lightweight jQuery plugin used to shorten a link using Bit.ly.

See a demo

##Instructions

Include jQuery and the plugin in the head or footer of your page.

<script src="//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>      <script src="/js/plugins/bitlr.js"></script>

Initialize the plugin and pass the function your api key, the link you want to shorten and the success callback function.

$.bitlr({ 	apiKey: 'XXXXXXXXXXXXXXXXXXXXX', 	link: 'http://google.com', 	success: function(newLink) { 	    console.log(newLink); 	} });

####Required Properties

  1. apiKey: string
    A string that defines your api key provided by Bit.ly.
  2. link: string
    A string that defines the link you'd like to shorten.
  3. success: function(newLink)
    A callback function that is triggered after the request is sucessful. The callback returns the new shortened link.

####Optional Properties

  1. anchor: bollean
    A boolean value that indicates whether or not the shortened link should be returned as an anchor (default: false).
  2. error: function()
    A callback function that is triggered after the request if the request is not sucessful.

#####Example:

$(function() { 	 	$.bitlr({ 		apiKey: 'XXXXXXXXXXXXXXXXXXXXX', 		link: 'http://google.com', 		success: function(newLink) {     		console.log(newLink); 		}, 		error: function() { 			console.log('There was an error.'); 		} 	}); 		 });

You May Also Like