How to get content from a remote URL via AJAX?
jQuery AJAX request is blocked because Cross-Origin
Console magazine
Cross-request blocking: the same origin policy prohibits reading a remote resource at http://www.dailymotion.com/embed/video/x28j5hv . (Reason: CORS header "Access-Control-Allow-Origin" is missing.)Cross-request blocking: the same origin policy prohibits reading a remote resource at http://www.dailymotion.com/embed/video/x28j5hv . (Reason: CORS request failed).
Cross-request blocking: the same origin policy prohibits reading a remote resource at http://www.dailymotion.com/embed/video/x28j5hv . (Reason: CORS header "Access-Control-Allow-Origin" is missing.)
Cross-request blocking: the same origin policy prohibits reading a remote resource at http://www.dailymotion.com/embed/video/x28j5hv . (Reason: CORS request failed).
The code
$.ajax({ url: "http://www.dailymotion.com/embed/video/x28j5hv", type:'GET', contentType: "html", crossDomain:true, success: function(data){ //$('#content').html($(data).html()); var src = $(data).html(); alert(src); return false; }
JSONP Ajax. .
JSONP
http://learn.jquery.com/ajax/working-with-jsonp/
$.ajax({ url: "https://api.dailymotion.com/video/x28j5hv?fields=title", dataType: "jsonp", success: function( response ) { console.log( response ); // server response } });
( ). crossDomain , (dailymotion.com) COORS.
, , - script , . - ? PHP, Python, ASP.NET ..? , "" script, HTTP- dailymotion . script Javascript-, script , script, COORS .
Try using a cURL request for a cross-domain.
If you work through third-party APIs or receive data through CROSS-DOMAIN, it is always recommended to use the cURL script (server-side), which is more secure.
I always prefer the cURL script.
Source: https://habr.com/ru/post/1598672/More articles:Solving XOR Equation Systems - c ++How to read data from a barcode scanner using JavaFX - javaSimplify the inverse function Z = X ^ (X << Y) - algorithmAsync method to return true or false in a task - c #How to sort one array the same as another? - javascriptTemplate of the base variant of the Variable template: no parameters or one? - c ++Java 8 lambda error: filter stream using a reduced filter collection. THEN map THEN collect - javaStandalone map for private property with navigation in iOS - iosInstall NPM on Linux - angularjsДекодирование содержимого в формате PDF в браузере Base64 - jsonAll Articles