我想从跨域网址获取html响应页面.
为此,我正在使用ajax请求,
$.ajax({ type: 'GET',url: "http://wcidevapps.com/salescentral/idisk/0001000383/iDisk",dataType: "jsonp",success: function (response) { $(response).find('li a').each(function () { listHref.push($(this).attr('href')); }); } });
但是在请求之后,没有回复任何结果.
解决方法
<script src="Scripts/jquery-1.4.1.js" type="text/javascript"></script> <script type="text/javascript"> function NameAFunctionName() { $.ajax({ url: 'http://wcidevapps.com/salescentral/idisk/0001000383/iDisk',type: 'GET',dataType: 'json',headers: { //WRITE IF THEIR HAVE SOME HEADER REQUEST OR DATA },crossDomain: true,success: function (data,textStatus,xhr) { console.log(data); },error: function (xhr,errorThrown) { console.log(errorThrown); } }); } </script>