0

I'm trying to include a script by including it in script src

<script type="text/javascript" src="http://some-site.com/script.js"></script>

Sometimes this fails with a 401 error. It is also a script, which is returned, which would be nice to read and execute here in any case. But for that I'd need to read the response.

I know there is an answer here, but I'm trying to do it without XHR, because the response on XHR is different (403), as is the content (otherwise I wouldn't care).

user857990
  • 1,140
  • 3
  • 14
  • 29
  • So what is the question? What do you want? – random_user_name Feb 08 '16 at 15:27
  • Why do you think it is coming back with "Unauthorized"? That sounds like something on the "some-site.com"'s side, possibly a little out of your control. – dmgig Feb 08 '16 at 15:32
  • @cale_b Can I read the response text `JSONP-stuff{"error":"Not authenticated"}` from JavaScript, despite it being delivered through a 401 when included in a script tag? – user857990 Feb 08 '16 at 19:07
  • @dgig It is in this one case yes. It's not that I can't get the information, - I can simply put the URL in the browser address bar and it'll give me the error text. So I'm not accessing anything I shouldn't. I was wondering if there is a programmatic way to do so right out of JavaScript. I'm not that familiar with JavaScript, and I thought asking here is where one asks. You sound like you are trying to insinuate, that I'm doing something illegal/wrong. – user857990 Feb 08 '16 at 19:10
  • No no, not at all. I just meant, if you are getting an "Unauthorized" that isn't generally something you'd have control over no matter how you tried to access it. – dmgig Feb 08 '16 at 19:13
  • Well, - I haven't made it yet, but I'm still hoping someone with more knowledge in JavaScript might know a workaround :) – user857990 Feb 08 '16 at 22:35

0 Answers0