I've been working on this problem for a few days and reaching out on this forum since I feel like I've exhausted my options. I have a form hosted on a Drupal 7 website and need to submit the form values to an external url. The form uses a POST request over the HTTPS protocol via jQuery.AJAX

  • Form works fine in Chrome, Firefox, and Safari
  • 我在IE10+控制台中收到以下错误(使用IE10+时,Ajax调用总是进入错误函数):

SCRIPT7002: XMLHttpRequest: Network Error 0x2ef3, Could not complete the operation due to error 00002ef3

I've tried the following:

  • 正在添加ContentType:

    // causes all of the jQuery callbacks to error out
    "application/json; charset=utf-8",
    
  • attempting an Ajax GET call before the actual POST (as suggested on another SO thread)

  • header( 'Content-Type: application/json; charset=utf-8' );添加到请求中

  • 设定crossDomain: true

已添加相应的CORS标题,表格代码粘贴如下:

$.ajax({
    url: "[URL]", //the page to receive the form data  
    crossDomain: true,
    type: "POST",
    data: dataString, //posting to API 
    dataType: "json", //the data type the function should expect back from the server     
    success: function(data) {         
        if (data.response_status == "1") { //error for at least 1 field
             //display error message 
             }
             else { 
             //display thank you label next to input
             }

        } else {
           //All form fields completed successfully! Redirect user to Thank you confirmation page            
        } 
     },
    error: function(jqXHR, textStatus, errorThrown) {
             alert("there is an error!");
             console.log("in error section");
             console.log("jqXHR: " + jqXHR);
             console.log("jqXHR.responseText: " + jqXHR.responseText);
             console.log("textStatus: " + textStatus);
             console.log("errorThrown: " + errorThrown);
             data = $.parseJSON(jqXHR.responseText);
             console.log("parseJSON data: " + data);                           
    }        
    });         
  });
});

I've read SCRIPT7002: XMLHttpRequest: Network Error 0x2ef3, Could not complete the operation due to error 00002ef3

Any guidance would be helpful! THANKS

推荐答案

The OP provided a WireShark capture showing that the server requested a certificate using the HTTPS CertificateRequest message and the client then immediately FINd the connection.

After configuring the server not to request a client certificate, the problem went away.

使用Fiddler还会使问题消失,因为除非您将其配置为这样做,否则Fiddler永远不会从浏览器请求客户端证书.

我想知道是否只有受影响的客户端计算机才有匹配的证书和/或CORS XHR请求上的withCredentials标志在此场景中是否相关.

Json相关问答推荐

使用Shell深入挖掘到最低的SON元素

Vega-Lite时钟(使用Vega-Lite中的计时器)

Flutter -控制器问题-JSON API

在Zig中解析JSON失败

Golang jsonrpc2 服务器在哪里监听?

转换为Json时忽略内部对象中的数组

使用 jolt 将对象数组转换为数组

如何使用 jq 在连续的 json 记录流上调用操作

如何在jolt中使用shift和modify-overwrite-beta

如何使用 React 从 NASA IMAGES API 中解构所需信息

如何从 JSON 中获取数据并通过 vb6 在网格中显示

从ruby中的json获取特定的键值

Flask 请求和 application/json 内容类型

Spring MVC控制器中的JSON参数

Rails 中奇怪的 JSON Javascript 问题

如何向(JSON)对象的原型添加方法?

java.lang.BootstrapMethodError:调用站点#4 bootstrap 方法的异常,初始化 retrofit 时

来自 Gson 的 JSON 字符串:删除双引号

FastAPI:如何将正文读取为任何有效的 json?

Laravel 5 控制器将 JSON 整数作为字符串发送