AJAX表单提交不适用于iOS设备

问题描述:

好的,这听起来是特定于插件的,但是我希望有人能解释为什么可能会发生这种情况.

Okay, so this sounds plugin-specific, but I'm hoping someone could explain WHY this might be happening.

我正在Wordpress中开发一个网站,我正在使用两个插件(联系表7)和一个用于CF7的集成Mailchimp插件.

I'm developing a site in Wordpress, and I am using two plugins, Contact Form 7, and an integrated Mailchimp plugin for CF7.

在表单提交时,它应该通过AJAX提供失败或成功响应,就是这样-我从来没有遇到过问题.但是,该站点上的数据仍在提交并且运行良好.但是,将重新加载页面,而不是AJAX响应.

On form submit, it should serve a failure or success response via AJAX and that's that - I've never had a problem. However, on this site the data is still submitted and is working fine. However, instead of an AJAX response, the page is reloaded.

仅在iOS上可用!

我首先想到的是这显然是某种冲突,所以我停用了插件,包括一个名为fullpage.js的jquery插件

My first thought was that it was obviously some sort of conflict, so I deactivated my plugins, INCLUDING a jquery plugin called fullpage.js

不变,仍在重新加载.我以为可能与我正在运行的jQuery版本有关,或者我如何将脚本排入队列,但仍然没有区别.

No change, still reloads. I thought it could be to do with the version of jQuery I'm running, or how i've enqueued my scripts, but still no difference.

有人对造成这种问题的原因有任何初步想法吗?

Does anyone have any initial ideas on what might cause this sort of issue?

更新:回去并在使用CF7的旧站点上进行了测试,并在iOS上遇到了同样的问题(我知道是很好的测试).因此,这一定是CF7和iOS的问题.还有其他人遇到过吗?

UPDATE: Went back and tested on an old site that uses CF7 and has same issues on iOS (great testing, I know). So, this must be an issue with CF7 and iOS. Anyone else experienced this?

iOS设备:

  • 已经淘汰了同步AJAX方法,仅使用异步
  • 不允许cachinig

尝试这样的事情:

$.ajax({
        url: your_URL,
        type: "POST",
        data: JSON.stringify(data),
        dataType: 'json',
        contentType: "application/json; charset=utf-8",
        async: true,
        cache: false,
        headers: { "cache-control": "no-cache" },
        success: function (data) {
            // do something
        },
        error: function (jqXHR, exception, errorThrown) {
            // do something
        }
    });

有关此主题的更多信息,请此处.

More on this topic found here.