Ajax调用在firefox中似乎失败了


Ajax call seems to fail in firefox

我目前正在进行一个项目,我使用Ajax调用将数据从JavaScript发送到PHP脚本。我试图在Stackoverflow上寻找答案,但没有成功,因此我提出了一个问题。

这段代码在我的chrome浏览器上工作正常,但当我在Firefox或Safari中尝试它时就失败了。

$.ajax({
  method: "POST",
  url: "index.php?option=com_lowbudgetrestvisual&task=sdc.connect&format=json",
  cache: false,
  data: {
    data: data
  },
  success: function(data, http, state) {},
  error: function(http, state, error) {
    console.log("Response -> failed");
    console.log("http : " + http);
    console.log("state: " + state);
    console.log("error: " + error);
  }
});

编辑:每当我尝试控制台登录google chrome时,它只是说Response -> success。当我尝试登录firefox时,我得到以下文本:

Response -> failed http = [object Object] state = error error =

编辑2:我正在制作form,然后将其提交给PHP script,以使用PHP将其保存在database中。另一个ajax调用在表单中,确保向表单中的用户和管理员发送电子邮件。我如何确保这两个工作是通过以下javascript代码:

    $('#sdc').on("click", function(e) {
        e.preventDefault(); 
   {{ then some codes and the ajax call }}
    });
    $('#sdc').on("click", function() {
        $("#userForm").submit(); 
    });

编辑3:我尝试了console.log("http : " , http);,这是我在控制台得到的:

    http = Object {
      readyState: 0,
      getResponseHeader: .ajax / v.getResponseHeader(),
      getAllResponseHeaders: .ajax / v.getAllResponseHeaders(),
      setRequestHeader: .ajax / v.setRequestHeader(),
      overrideMimeType: .ajax / v.overrideMimeType(),
      statusCode: .ajax / v.statusCode(),
      abort: .ajax / v.abort(),
      state: .Deferred / d.state(),
      always: .Deferred / d.always(),
      then: .Deferred / d.then(),
      11 more…
    }

这段代码在firefox中运行良好。请检查firefox浏览器版本和jquery。请检查服务器php文件路径

<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
<script>
    $.ajax({
  method: "POST",
  url: "test1.php",
  cache: false,
  data: {
    data: 'test'
  },
  success: function(data, http, state) {},
  error: function(http, state, error) {
    console.log("Response -> failed");
  }
});
</script>