【问题标题】:cross-domain ajax request get 412跨域ajax请求得到412
【发布时间】:2013-11-25 14:30:14
【问题描述】:

我必须从 iPad 跨请求访问 tomcat webapp,有时这可行,但如果您发送请求重复,tomcat 将返回 412 代码。帮助!
ios的代码是

$.ajax({
    type:"POST",
    url:[this is not a link]("http://192.168.1.222:8080/cmcp/doLogin"),
    timeout:600000,
    data: JSON.stringify({userName:"admin",password:"admin"}),
    dataType:"json",
    contentType: "application/json",
    success: function(nowData,textStatus,XMLHttpRequest )
    {

    },
    error :function(msg) {

    }
}); 

【问题讨论】:

    标签: ajax http tomcat cross-domain


    【解决方案1】:

    使用数据类型JSONP 而不是JSONJSONP 是跨域 Ajax

    的可行解决方案
    dataType: 'JSONP'
    

    请查看ExaplesCross-domain Ajax -- brief introduction

    【讨论】:

    • 如果是跨域问题,它会帮助你。
    猜你喜欢
    • 2013-03-06
    • 1970-01-01
    • 1970-01-01
    • 2015-01-26
    • 2013-08-20
    • 2012-04-15
    • 2011-07-05
    • 1970-01-01
    相关资源
    最近更新 更多