framework7 icon indicating copy to clipboard operation
framework7 copied to clipboard

Handling Failing xhr requests. Bug?

Open manish2535 opened this issue 8 years ago • 4 comments

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.

  1. Open the Fiddle, (have the debugger open)
  2. 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.

manish2535 avatar Jul 06 '18 01:07 manish2535

Never use async: false, set it to true and it will work as expected

nolimits4web avatar Jul 06 '18 08:07 nolimits4web

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- .

manish2535 avatar Jul 06 '18 13:07 manish2535

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

nolimits4web avatar Jul 06 '18 13:07 nolimits4web

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- .

manish2535 avatar Jul 06 '18 13:07 manish2535