I am trying to implement the Google URL shortener API with the help of jQuery by making an AJAX call. I have done something like this:
$(function() {
$('#btnshorten').click(function() {
var longURL = $('#tboxLongURL').val();
$.ajax({
url: 'https://www.googleapis.com/urlshortener/v1/url?shortUrl=http://goo.gl/fbsS&key=AIzaSyANFw1rVq_vnIzT4vVOwIw3fF1qHXV7Mjw',
type: 'POST',
contentType: 'application/json; charset=utf-8',
data: '{ longUrl: "' + longURL +'"}',
dataType: 'json',
success: function(response) {
var result = eval(response); // Evaluate the J-Son response object.
}
});
});
});
But it is generating an error in IE. It is showing "Access is denied" and in Firebug it is showing "405 method not allowed." Am I doing something wrong here?