Home > Uncategorized > ‘Promise’ is undefined #IE11

‘Promise’ is undefined #IE11

1_Bf17KrH3fJo09LTKHRYJcw

Javascript promises are a key feature of modern asyncronous javascript, but, if you’re developing a mass-market website, cross-browser support may trump the syntactical sugar, especially if you’re facing down business-types, rather than other developers.

Specifically, IE11 does not support Javascript promises, and if you are looking to support a wide range of browsers, then there is a polyfill available from Taylor Hakes, that can get round that error message, that simply says “‘Promise’ is undefined” in IE11

So, working with an example from SMTPJS v3 – which now uses promises, and arrow functions, you need include the following script tags;

https://cdn.jsdelivr.net/npm/promise-polyfill@8/dist/polyfill.min.js
https://smtpjs.com/v3/smtp.js

Then adjust the code to use an inline function instead of an arrow function:

Email.send({
Host : “email-smtp.eu-west-1.amazonaws.com”,
Username : “******”,
Password : “*****”,
To : ‘them@gmail.com’,
From : “you@website.com”,
Subject : “This is the subject”,
Body : “My useragent is ” + navigator.userAgent
}).then(
function(message) { alert(message) } // FOR IE
);

Advertisements
Categories: Uncategorized
  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: