weixin_33725272 2016-10-12 11:54 采纳率: 0%
浏览 24

IE 11 Ajax问题

So internet explorer does it again. I currently have a validation.php file where values in a text box are sent for validation. The text-box value is read and then a result is given to say if this is valid or not. This works perfectly on any other browser but IE. The ajax request specifically doesn't work. Any help would be appreciated. The script below is in charge of taking the data from the input-box and sending the request via AJAX.

 $(document).ready(function () {
    $("#email").blur(function () {
      var username = $(this).val();
      if (username == '') {
        $("#availability").html("Empty Input");
      }
      else{
        $.ajax({
          url: "validation.php?uname="+username
        }).done(function( data ) {
        if (data.includes("result-from-validation")){
            //DO SOMETHING
        }
        else {
         // DISPLAY ERROR
        } 
        });   
      } 
    });
  });
  • 写回答

1条回答 默认 最新

  • weixin_33713503 2016-10-12 11:57
    关注

    Two issues:

    1. username really, really should be URI-encoded before being sent as part of a URI: url: "validation.php?uname="+encodeURIComponent(username) (or let jQuery do it by passing as data: {uname: username}).

    2. Array#includes and String#includes are both new things in JavaScript. It's no surprise that an older browser doesn't have them.

      Both can be polyfilled if desired (see links above), or you can probably use indexOf: if (data.indexOf("result-from-validation") != -1)

    评论

报告相同问题?

悬赏问题

  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 保护模式-系统加载-段寄存器
  • ¥15 电脑桌面设定一个区域禁止鼠标操作
  • ¥15 求NPF226060磁芯的详细资料