I'm trying to get and parse data from a remote cross-domain site with jQuery.To avoid Same-Origin-Policy and Cross-Domin issue, I use jsonp.
<html>
<head>
<title>Ajax Sample</title>
<script type="text/javascript" src="http://code.jquery.com/jquery-1.7.min.js"></script>
</style>
<script>
$(document).ready(function(){
//Obviously the service wont give a JSON format response
var url='http://stackoverflow.com/search?q=Cross+domain';
$.ajax({
url:url,
dataType: 'jsonp',
success:function(data){
console.log(data);
},
error:function(){
alert("Error");
},
});
});
</script>
<body>
</body>
</html>
But what I got is error
:
Resource interpreted as Script but transferred with MIME type text/html: "http://stackoverflow.com/search?q=Cross+domain&callback=jQuery1708665772899985313_1374154944485&_=1374154944492"
and
Uncaught SyntaxError: Unexpected token <
So how to make it in a right way?