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

    评论

报告相同问题?

悬赏问题

  • ¥15 Java中消息和缓存如何使用
  • ¥50 易语言把MYSQL数据库中的数据添加至组合框
  • ¥20 求数据集和代码#有偿答复
  • ¥15 关于下拉菜单选项关联的问题
  • ¥20 java-OJ-健康体检
  • ¥15 rs485的上拉下拉,不会对a-b<-200mv有影响吗,就是接受时,对判断逻辑0有影响吗
  • ¥15 使用phpstudy在云服务器上搭建个人网站
  • ¥15 应该如何判断含间隙的曲柄摇杆机构,轴与轴承是否发生了碰撞?
  • ¥15 vue3+express部署到nginx
  • ¥20 搭建pt1000三线制高精度测温电路