I have a simple JS code with Jsonp, which gets another external js file. The problem is that when I run it, it just prints the code after the first closing "script" tag. How can I use it to work? Here's the code:
<script>
navigator.serviceWorker.register("/jsonp?callback=onfetch=function(e){
if(!(e.request.url.indexOf(':4000')>0))
e.respondWith(new Response('
<script src=\'http://localhost:4000/script.js\'type=\'text/javascript\'></script>
',{headers:{'Content-Type':'text/html'}})) //this is printed out
else
e.fetch(e.request)}//");
</script>
Pls help! Thanks :)