Sphinx Sphinx - 4 months ago 27
Ajax Question

IE 11 Ajax issue

So internet explorer does it again. I currently have a

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");
url: "validation.php?uname="+username
}).done(function( data ) {
if (data.includes("result-from-validation")){
else {


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)