How to get content from remote url via ajax?
jQuery ajax request being block because Cross-Origin
Console Log
Cross-Origin Request Blocked: The Same Origin Policy disallows reading
the remote resource at http://www.dailymotion.com/embed/video/x28j5hv.
(Reason: CORS header 'Access-Control-Allow-Origin' missing).
Cross-Origin Request Blocked: The Same Origin Policy disallows reading
the remote resource at http://www.dailymotion.com/embed/video/x28j5hv.
(Reason: CORS request failed).
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;
}
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…