相关疑难解决方法(0)

实施Google URL缩短程序API的跨域问题

我试图通过进行AJAX调用在jQuery的帮助下实现Google URL缩短器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.
            }
         });
    }); 
});
Run Code Online (Sandbox Code Playgroud)

但它在IE中产生错误.它显示"访问被拒绝",在Firebug中显示"405方法不允许".我在这里做错了吗?

api jquery google-url-shortener

5
推荐指数
2
解决办法
4165
查看次数

标签 统计

api ×1

google-url-shortener ×1

jquery ×1