In the Chrome app, Cross-Origin

Chrome has its own Greasemonkey, anyway, it has many limitations. One of them is that its xmlhttprequest does not support Cross-Origin. So is there a way to make it work?

thank

+5
source share
2 answers

, script Opera, GM_xmlhttpRequest. , YQL jQuery, :

var getCrossDomain = function (url, callback, maxage) {
        if (typeof (url) !== 'undefined') {
            var yql = 'http://query.yahooapis.com/v1/public/yql?q=' + encodeURIComponent('select * from html where url="' + url + '"') + '&diagnostics=false&format=xml&callback=?&_maxage=';
            if (typeof (maxage) === 'undefined') {
                yql += '10000'; // Value is in ms
            }
            $.getJSON(yql, function (data) {
                if (typeof (callbackX) === 'function') {
                    callback(data.results[0]);
                }
            }).fail(function (jqXHR, textStatus, errorThrown) {
                // Some code here to handle a failed request
            });
        }
    };

http://www.yqlblog.net/blog/2010/03/12/avoiding-rate-limits-and-getting-banned-in-yql-and-pipes-caching-is-your-friend/ maxage.

+1

All Articles