#16138 closed defect (wontfix)
dojo/request/script error function is not working
Reported by: | dernafees | Owned by: | Bryan Forbes |
---|---|---|---|
Priority: | low | Milestone: | 1.11 |
Component: | IO | Version: | 1.8.0 |
Keywords: | Cc: | ||
Blocked By: | Blocking: |
Description
When trying the below code with any error such as http 404. the error function is not reached or executed.
require(["dojo/request/script"], function(script){ script.get("something.js", { jsonp: "callback" }).then(function(data){ // Do something with the response data }, function(err){ // Handle the error condition }); // Progress events are not supported });
Change History (8)
comment:1 Changed 8 years ago by
Component: | General → IO |
---|---|
Owner: | set to Bryan Forbes |
comment:3 Changed 7 years ago by
Any progress on this? I bet it is really tough and maybe not possible.
comment:4 Changed 7 years ago by
Resolution: | → wontfix |
---|---|
Status: | new → closed |
dojo/request/script
is implemented using script injection. There is no event triggered when a script element fails to load. As such, the error case in dojo/request/script
cannot be triggered because of something like a 404. The recommended approach is to set a reasonable timeout
parameter for your JSONP requests so that if it does 404, the timeout will eventually be reached and cause an error.
comment:5 Changed 6 years ago by
I opened https://github.com/dojo/dojo/pull/140 to resolve this issue. Per http://www.w3.org/TR/html5/scripting-1.html#the-script-element, an 'error' event should be emitted on the script when there is an error, such as a 404 error. This does not occur in IE8, however, but when used with timeouts, it can help the request to fail faster.
comment:6 Changed 5 years ago by
Milestone: | tbd → 1.11 |
---|---|
Priority: | undecided → low |
Thanks Nick, landed in https://github.com/dojo/dojo/commit/6fe6d9b7465c8cea7e69594816e2bf6d1aa94372
comment:7 Changed 4 years ago by
This is marked as "wontfix" and I only see it in master, not any older branches - is there no plan to backport this?
comment:8 Changed 4 years ago by
It was not backported further as I don't believe it cleanly backported. Would consider a PR for older releases.
I see this exactly the same. I was expecting the dojo/request/notify to work the same as dojo/request but it does not, request.start works, but none of the other events for errors. request.load works as well.