Skip to content

Fix ajax request callbacks - #276

Merged
aristath merged 1 commit into
developfrom
filip/fix-ajax-requests
Feb 20, 2025
Merged

Fix ajax request callbacks#276
aristath merged 1 commit into
developfrom
filip/fix-ajax-requests

Conversation

@ilicfilip

Copy link
Copy Markdown
Collaborator

Context

We do AJAX requests from one function, to which we pass data, URL, success and fail callbacks.
In that function we're registering new callback on the http.onreadystatechange event, success callback was executing fine but fail callback was triggered on every state change - mainly on when http.readyState values were 2 & 3 (headers received & response downloading), which is wrong.

I have changed it so fail callback is triggered only when request is done, but response code is not 200.

I noticed this while working on new Onboarding flow, scanning posts was triggered twice and there were multiple 'Failed to scan posts. Retrying...' messages in the console, which looked suspicious.

Summary

This PR can be summarized in the following changelog entry:

Quality assurance

  • I have tested this code to the best of my abilities.
  • I have added unit tests to verify the code works as intended.
  • I have checked that the base branch is correctly set.

@ilicfilip
ilicfilip requested a review from aristath February 18, 2025 12:55
@github-actions

github-actions Bot commented Feb 18, 2025

Copy link
Copy Markdown
Contributor

Test merged PR on Playground
Test this pull request on the Playground or download the zip.

@jdevalk

jdevalk commented Feb 18, 2025

Copy link
Copy Markdown
Member

I'll let @aristath review too, but this looks good to me.

@aristath
aristath merged commit 979e46f into develop Feb 20, 2025
@aristath
aristath deleted the filip/fix-ajax-requests branch February 20, 2025 06:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants