Handling Failing xhr requests. Bug?
This is a (multiple allowed):
-
[x] bug
-
[ ] enhancement
-
[ ] feature-discussion (RFC)
-
Framework7 Version: 2.5.16.
-
Platform and Target: CORDOVA, IOS, ANDROID.
-
Live Link or JSFiddle: https://jsfiddle.net/90ot5hz7/11/
What you did
I have a case where sometimes my server is down and when the app tries to make the call, the app just errors out. I would expect the ajax call to land in the ERROR function block where I can handle it properly but this does not happen.
- Open the Fiddle, (have the debugger open)
- Click on the About Menu. You will see instead of going to the AJAX call's Error block, it just throws a error.
Uncaught DOMException: Failed to execute 'send' on 'XMLHttpRequest': Failed to load 'https://www..com/'
Am I doing something wrong here?
Expected Behavior
If a ajax request fails for any reason, it should go into the ERROR block.
Actual Behavior
It just errors out which can be seen in the console log and never goes into the Ajax call's ERROR block like the documentation says.
Never use async: false, set it to true and it will work as expected
Thabks for the quick reply. I am using the Async false for some of my calls because i want them to work synchronously. Shouldn't this work even for synchronous calls?
On Fri, Jul 6, 2018, 4:06 AM Vladimir Kharlampidi [email protected] wrote:
Closed #2485 https://github.com/framework7io/framework7/issues/2485.
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/framework7io/framework7/issues/2485#event-1719713414, or mute the thread https://github.com/notifications/unsubscribe-auth/AEcp9tj4JDkvfXUp60yWV82yLJKt9k3tks5uDxp3gaJpZM4VEvV- .
Shouldn't this work even for synchronous calls?
No, it won't work in this case. Use try/catch in this case. But it is a very bad practise to use sync requets
Ok gotch ya. Thanks.
On Fri, Jul 6, 2018, 9:02 AM Vladimir Kharlampidi [email protected] wrote:
Shouldn't this work even for synchronous calls?
No, it won't work in this case. Use try/catch in this case. But it is a very bad practise to use sync requets
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/framework7io/framework7/issues/2485#issuecomment-403027633, or mute the thread https://github.com/notifications/unsubscribe-auth/AEcp9oNTbkqIlJvEwgF8LpCjDrXVzLYuks5uD1_3gaJpZM4VEvV- .