<?php
$(document).ready(function(){
$("#shorten").click(function(){
var url = $('#url').val();
$.ajax({
type:'POST',
url:'index.php',
data:"shorten=true&url="+url,
success: function(msg){
if(msg == "URL is not valid"){
$('#error').hide('slow');
$('#error').text(msg);
$('#error').show('slow');
$('#correct').hide('slow');
}else{
$('#correct').hide('slow');
$('#correct').text(msg);
$('#correct').show('slow');
$('#error').hide('slow');
}
}
});
});
});
?>