Create Short URLs Using Jquery and Ajax.

Posted: September 5, 2013 in Ajax, Jquery
Tags: , , ,

How to create short URLs using Jquery and Ajax. Many tutorials available on web about short URLs using server sidescript, this script works on client side. It is easy just 5 lines of code calling API.You have to modify the username and API key. Use it and make URLs shorts and neat.

Live Demo

Javascript Code
You have to create an account on and modify the username and API key.

// <![CDATA[
javascript” src=”
// ]]>
<script type=”text/javascript”>
{//bit_url function
function bit_url(url)
var url=url;
var username=”username”; // username
var key=” API key”;
$(“#result”).html(‘<a href=”‘+bit_url+'” target=”_blank”>’+bit_url+'</a>’);
var url=$(“#url”).val();
var urlRegex = /(\b(https?|ftp|file):\/\/[-A-Z0-9+&@#\/%?=~_|!:,.;]*[-A-Z0-9+&@#\/%=~_|])/ig;
var urltest=urlRegex.test(url);
alert(“Bad URL”);
</script>//HTML Code
<input type=”text” name=”url” id=”url“/>
<input type=”submit” id=”short” value=”Submit”/>
<div id=”result”></div>

This javascript code $(“#short”).click(function(){}short is the id name of the submit button. Using $(“#url”).val() calling input box value.

source taken from 9lessons

Leave a Reply

Please log in using one of these methods to post your comment: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.