camsong / fetch-jsonp

Make JSONP request like window.fetch
998 stars 158 forks source link

error in ie8 #47

Closed mraiguo closed 3 years ago

mraiguo commented 6 years ago

When I use the example of ie8(index-ie8.html)it report an error: TypeError: 对象不支持此属性或方法 image

kaidjohnson commented 6 years ago

I can't read Chinese, but reading through the source code, I did spot a Date.now() which will cause problems in IE8. https://github.com/camsong/fetch-jsonp/blob/master/src/fetch-jsonp.js#L8

Should either change documented support to IE9+ or replace with new Date().getTime();.

Workaround is to include a Date.now() polyfill in your application above the code that uses fetch-jsonp:

if (!Date.now) {
  Date.now = function () {
    return new Date().getTime();
  };
}
mraiguo commented 6 years ago

@kaidjohnson sorry,I've found it,But forget to submit a pr,thanks