From 874972fddde2de797cfaf7612fd1719cd66df883 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?tangentguo=28=E9=83=AD=E8=BF=85=29?= Date: Fri, 18 May 2018 17:57:24 +0800 Subject: [PATCH] when script on error callback should be call firsttime --- index.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/index.js b/index.js index 1ee62b3..9a1fef3 100644 --- a/index.js +++ b/index.js @@ -91,6 +91,10 @@ function jsonp(url, opts, fn){ // create script script = document.createElement('script'); script.src = url; + script.addEventListener('error',function(e) { + cleanup(); + if (fn) fn(e); + },false) target.parentNode.insertBefore(script, target); return cancel;