weixin_33724059 2014-03-04 15:07 采纳率: 0%
浏览 33

jQuery Ajax永远无法正常工作

i have this code and it always end up with error block. I spent four hours on searching but nothing helped. I want to load HTML data from a URL

$.ajax({
url: 'http://google.com',
//data: {action : 'login', formData : $('#check-user').serialize()},
dataType: 'html',
type: 'get',                   
async: 'false',
//contentType: 'application/json; charset=utf-8',
//dataType: 'json',
beforeSend: function(xhr) {
    //xhr.overrideMimeType( "text/plain; charset=x-user-defined" );
    // This callback function will trigger before data is sent
    //$.mobile.showPageLoadingMsg(true); // This will show ajax spinner
},
complete: function() {
    // This callback function will trigger on data sent/received complete
   // $.mobile.hidePageLoadingMsg(); // This will hide ajax spinner
},
success: function (result) {
    alert(result);
    if(result.status) {
        //$.mobile.changePage("#second"); 
        alert("Change Page");
    } else {
        alert('Logon unsuccessful!'); 
    }
},
error: function (xhr, status, error) {
    // This callback function will trigger on unsuccessful action             
    //var err =  eval(xhr.responseText);
    //alert(xhr.Message);
    alert('Network error has occurred please try again! ' );
}
});                   
  • 写回答

2条回答 默认 最新

  • weixin_33726313 2014-03-04 15:12
    关注

    Take a look at:

    http://en.wikipedia.org/wiki/Same-origin_policy

    it is possible to load scripts and images from external sites but not html.

    You'll need to scrape it server side

    评论

报告相同问题?

悬赏问题

  • ¥100 set_link_state
  • ¥15 虚幻5 UE美术毛发渲染
  • ¥15 CVRP 图论 物流运输优化
  • ¥15 Tableau online 嵌入ppt失败
  • ¥100 支付宝网页转账系统不识别账号
  • ¥15 基于单片机的靶位控制系统
  • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度