【发布时间】:2011-06-09 02:55:36
【问题描述】:
我正在尝试通过 AJAX 调用在 jQuery 的帮助下实现 Google URL Shorter API。我做过这样的事情:
$(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.
}
});
});
});
但它在 IE 中生成错误。它显示“访问被拒绝”,在 Firebug 中显示“405 方法不允许”。我在这里做错了吗?
【问题讨论】:
标签: jquery api google-url-shortener