Internet Explorer 11 - AJAX调用未触发 [英] Internet Explorer 11 - AJAX Call not firing

查看:240
本文介绍了Internet Explorer 11 - AJAX调用未触发的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我陷入了一个错误的中间。我开始使用BrowserStack来验证我当前针对Windows IE和EDGE的项目,我在IE 11中遇到了一个特殊问题。

I am stuck in the middle of a bug. I began to use BrowserStack to validate my current project against Windows IE and EDGE and I got a particular issue with IE 11.

我首先遇到了一个我解决的问题FormData没有任何.get()方法,我使用了NPM formdata-polyfill。

I first got an issue that I solved which was that FormData did not have any .get() methods, and I used the NPM formdata-polyfill for that.

我正在使用FormData处理本机JS登录表单和XMLHTTPRequest,似乎AJAX调用根本没有触发。

I am working on a native JS login form, using FormData and XMLHTTPRequest, and it seems that the AJAX call is not firing at all.

点击提交按钮,而不是发送到我的特定登录URL,POST请求被触发到当前页面本身。

When clicking on the submit button, instead of sending to my particular login URL, the POST request is fired to the current page itself.

因此,显然,没有捕获事件并且没有执行JavaScript。

So, obviously, no event is catched and no JavaScript is executed.

我的JavaScript是使用WebPack编译的,我用来获取登录表单并附加适当事件的行如下:

My JavaScript is compiled using WebPack, and the lines I use to get the login form and attach proper events to it are the following :

    var formLogin = document.querySelector( "#form-login" );

    if ( formLogin !== null )
    {
        var email    = document.getElementById( "email" );

        formLogin.addEventListener( "submit", _.validateLoginForm );
        _.formInstance.init( formLogin );

        _.inputUtil.disableField( '#btn-submit-email' );
        _.inputUtil.disableField( '#btn-submit-password' );

        utils.addAndDispatchEvent( '#email', 'input', _.inputUtil.disableSubmitIfFieldIsEmpty( '#btn-submit-email' ) );
        utils.addAndDispatchEvent( '#password', 'input', _.inputUtil.disableSubmitIfFieldIsEmpty( '#btn-submit-password') );

        email.addEventListener( "invalid", _.onInvalidEmail );
    }

```

JS文件已正确加载到。

The JS file is properly loaded to.

我无法得到它可以来自哪里,因为它适用于任何其他浏览器(包括我获得polyfill后的Edge) )。

I do not get where it can come from as it works well on any others browsers ( including Edge after I got the polyfill ).

如果您有任何想法,请告诉我们!

If you have any ideas, let me know !

感谢收听。

推荐答案

我的问题是我需要覆盖我对不同的电话e.preventDefault()
by
e.preventDefault? e.preventDefault():( e.returnValue = false);

My issue here was that I needed to override my call to different e.preventDefault() by e.preventDefault ? e.preventDefault() : ( e.returnValue = false );

IE上支持的更好。

从以下帖子获得此信息: event.preventDefault()函数在IE中不起作用

Got this information from the following post : event.preventDefault() function not working in IE

然后我得到了不正确支持的事件和CustomEvent类的aditionnal问题所以我通过添加Babel Transpiler添加了一些polyfill以避免使用ES2015但兼容JS。

Then I got aditionnal issues with the Event and CustomEvent class not properly supported so I added a few polyfills by adding Babel Transpiler to avoid using ES2015 but compatible JS.

仍然存在完全支持IE 11的一些问题,但这个问题已修复。

Still having some issues with supporting IE 11 completely but this one is fixed.

这篇关于Internet Explorer 11 - AJAX调用未触发的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆