【问题标题】:XMLHttpRequest Exception 101 when i try to call POST rest with jquery当我尝试使用 jquery 调用 POST 休息时,XMLHttpRequest 异常 101
【发布时间】:2013-05-30 16:32:51
【问题描述】:

我正在使用 jquery、jersey 和 json。 当我尝试调用邮政服务时,我收到此错误

Access-Control-Allow-Origin 不允许 Origin null。 未定义 * 错误:NETWORK_ERR:XMLHttpRequest 异常 101

我的客户代码

$.ajax({url: jurl, type: 'POST', dataType : 'json', headers: {accept:"application/json"},data: inData , cache : false, async : false, contentType : "application/json; charset=utf-8", 

我的服务器代码

@POST
@Path(ReferentialPath.PLAYER_RESOURCE_PATH)
@Consumes(MediaType.APPLICATION_JSON)
public Response createPlayer(CreatePlayerIn cPlayer) {
    try {
        String res = dao.create(player);

        UriBuilder ub = uriInf.getAbsolutePathBuilder();
        URI createdUri = ub.path(res).build();
        return Response.created(createdUri).build();

    } catch (Exception e) {
    }
}

谁能告诉我可能是什么问题

【问题讨论】:

    标签: java ajax json rest jersey


    【解决方案1】:

    这里我猜你的客户端和服务器之间一定有防火墙。 HTTP 代码 101 表示您的 http 请求已被您的网络设备过滤。所以改变你的网络并直接连接你的服务器。然后再试一次。

    【讨论】:

      【解决方案2】:

      您似乎正在尝试发布到另一个域。
      可能的问题wiki
      可能的解决方案:你应该阅读这个SO question

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2013-01-17
        • 2012-12-11
        • 2020-11-11
        • 1970-01-01
        • 2012-09-10
        • 2018-05-10
        • 1970-01-01
        • 2011-03-21
        相关资源
        最近更新 更多