I'm loading cross domain html page with jQuery AJAX.
My problem is to return or equal the response data (target's html code) .
var html = "";
get("http://google.com");
function get( url ){
$.ajaxPrefilter( function (options) {
if (options.crossDomain && jQuery.support.cors) {
var http = (window.location.protocol === 'http:' ? 'http:' : 'https:');
options.url = http + '//cors-anywhere.herokuapp.com/' + options.url;
}
});
$.get(url,function (response) {
// Here is the problem
});
}
In the $.get() method I tried to :
html = result ;
return result ;
Both tries didn't work.
Is there any similar way to 'export' the response data to a global scope var ?
P.S - I've tried to use a function with a parameter to return the response . It worked perfectly but that is not what I want at all.
Aucun commentaire :
Enregistrer un commentaire