Ajax not working properly - improper XmlHttpRequest execution on Brave Desktop browser

Description of the issue:
When expecting an ajax response in a alert pop up back to the user, I am receiving the wrong response. Problem with xmlhttp.onreadystatechange = function() or XmlHttpRequest();

Exact URL of the website in question:

Did the issue present with default Shields settings? (yes/no) Yes

Does the site function as expected when Shields are turned off? No

Is there a specific Shields configuration that causes the site to break? If so, tell us that configuration. (yes/no):
Does the site work as expected when using Chrome?
Brave version (check About Brave):


In order to replicate, you do not have to use the discord login but it was validated originally using this method. The user app uses Discord ID - and use your Discord Username to log a vote to a user. No data is collected or saved, im just troubleshooting oauth against my site and noticed this behaviour exists in Brave but not in Chrome, Edge, or Safari (conveniently Brave is my main browser so I noticed the issute). It turns out I don’t even need a user to replicate this issue with their discord login, you can simply navigate directly to https://fights.today/test-vote/ and replicate with a non signed in user.

Steps to recreate
-Login as discord, or browse directly to the page https://fights.today/test-vote/ - if going directly to the page skip the next step.
-Follow through to index.html after successful login (link on the welcome page after login)
-Cast a vote selecting either fighters image and then submit.
-Note you will have to perform this step twice in order to receive the error of trying to submit a duplicate entry.

This behaviour works as expected on all other browsers. However on Brave, you will just continue to get “Vote Submitted Successfully”
You can validate the submit_vote.php response in the developer tools that the appropriate response is being received after submit_vote.php, however the msg box is not working proper in Brave.

Brave Browser Response:



One helpful thing I noticed, the Ajax bubble seems to appear early in Brave, instead of the other browsers, maybe this is why its not capturing the appropriate message:

You can see above, the payload is empty at the time the bubble appears

Here is my Javascript function, if there is any way to help by optimizing my code to handle this on my side, rather than it being a Brave Browser issue:

function submitVote() {
    if (selectedFighter) {
        var xmlhttp = new XMLHttpRequest();
        xmlhttp.onreadystatechange = function() {
            if (this.readyState == 4 && this.status == 200) {
                var response = this.responseText;
                if (response == "Vote submitted successfully!") {
                } else if (response == "You have already voted for this fighter!") {
                } else {
                    alert("An error occurred. Please try again.");
        xmlhttp.open('POST', 'https://fights.today/test-vote/submit_vote.php', true);
        xmlhttp.setRequestHeader('Content-type', 'application/x-www-form-urlencoded');
        xmlhttp.send('fighter=' + selectedFighter);
    } else {
        alert('Please select a fighter to vote for!');

Just confirming the behaviour on brave mobile is as expected. So the issue is brave desktop browser only

1 Like

Hi there @futurepr0n please accept my apologies for this inconvenience. Please try creating a new profile on your desktop version of Brave and load that site to see if the issue persist there.

To create a profile go to main menu > create a new profile, and do not change any profile setting.

Let me know if that works.

I don’t see how that suggestion solves anything or proves anything. As mentioned this behaviour is occurring in brave desktop browser. No profiles are used, incognito/private browsing mode is being used to test along with different computers. All other browsers behave as expected and you can verify or test the website yourself. No discord or any authorization required.

Yes, profiles are used. When you start using the browser, it goes by your default browser profile. You’re able to create additional profiles. They asked you to create a new browser profile and to test it because it would help to figure out possible issues, such as if you have an issue in cookies, if an extension is interfering, etc.

You might want to try listening to Support when they come to help, rather than argue.

Btw, when clicked on it within Brave:

FYI -the behaviour corrected itself without me creating another profile. As it happened later suddenly I was seeing the correct behaviour without doing anything at all.

You interpret me how you will, I was merely asking how it would help. Your reasons are the same thing that happens when you run in private and close the browser completely as I was doing in my tests. Along with running on another machine as mentioned. But carry on, I was just trying to help.
Edit — and thank you for testing.
I did try to mark as solved but thank you for also coming in to add more visibility


All good. I saw it marked solved but then saw your comment, so figured maybe one of the Support had marked it solved instead. Wanted to make sure to respond and was answering you a bit on it.

As you can imagine, we get enough people here who will argue and debate rather than helping through troubleshooting steps to identify issues. It at least was appearing in the comment I responded to that you were doing the same, questioning how they dare suggest you create a new profile. That said, I always do try to check things on my end any time I’m talking to people. If I can’t replicate, then I tend to have to rely on various things on the end of the person having the difficulty.

Anyway, glad seems to be fine now. (^_^)

Unfortunately this morning I am still getting the odd issue where it behaves same as I mentioned before. I wonder why though, as mentioned, I can see the behaviour in the Network section in Developer tools that I get my response bubble, before submit_vote.php appears in network, so it looks like the pop up alert happens before the php response comes back - I wonder is there any way that you can replicate the issue there - or if there is anything in my javascript that could be optimized and work better. I just know that all other browsers aren’t having the same issue and when using the dev tools I see the order of things proper. Its inconsistent for sure though, because I see it work fine when going to a new session. I wonder if there is a way for me to handle it on my web site so that it would never show the wrong message to someone. Thats a noodle scratcher…

Edit: as a former support person myself, I understand, and I hate the thankless nature of the job. Its a dying art that is underappreciated until you have nothing but chat bots or automatic phone responses than you really understand and appreciate another person on the other end. I was just hoping to help, I don’t know if anything on the Brave side is actually responsible because I understand its based on the same framework(?) as other browsers, but for whatever reason I just have noticed this quirk.

I removed the Solution since you’re saying still happening.

May not help much, still would ask you try to do a fresh browser profile. If you do the new profile and it works consistently, then we know it’s cookies, settings, or extensions and would have to kind of go from there.

Let me tag @fanboynz and @SaltyBanana to see if either might be able to swing by with ideas. Typically I’d tag Mattches but been tagging him a lot, so trying to divide it up, lol.

Also, if you’re not aware, I’m a normal User who spends a lot of time helping here. I’m like a very base level of support and essentially just try to triage issues and collect base info. When it comes to things like the Console and all, I know nothing.

I will say though, in trying to test now, it no longer lets me do it without logging in. Quite frankly, I’m not going to log in with my Reddit or Discord. Perhaps I should just create a junk account for when things like this come up, but haven’t done so yet and try not to link connections to accounts to places I don’t generally use.

thats fine you dont need to login (I only have access to Reddit Username and Discord Username, I dont have the callback setup for requesting any other permissions, thats not the intent of my neat little app/project, I just want to make it easiest as possible for a user to vote on something without needing to sign up for an account)

From not being logged in - you should be able to return the same effect - after you have tried to vote for either fighter once - if its successful, then the database will have logged enough results to start hitting you back with “You have already voted” as a popup.

I have been emptying the database and retesting myself, so if you noticed you were able to vote, or anything else was happening that was probably because I was doing something at the exact same time.

I will try to see if I can recreate with the new profile, I appreciate your help, again - you only need to go to - https://fights.today/test-vote/index.html – you wont need to test the auth part, I have that working fine and its not necessary to login to vote.

Ah, I hit the wrong link. That explains it, lol. Let’s see then.

So yeah, still saying I already voted.

I can’t say that its consistent, and yesterday given the order of how things were being returned and presented I thought maybe I could help to isolate something wrong but since it can’t be recreated by yourself we can probably keep it closed as solved and if anyone else ever runs into something similar they may be able to search this ticket then help reference it along with more information that could be useful. Thanks for the help.

Just FYI - to show, Im taking the least permissions, and you need to explicitly allow - it doesn’t one click grant me access to everything on a user. Soon I’ll put together a TOS page that fully outlines my intent

Hi @futurepr0n

Apologies for the delay. I see that @Saoiray post was marked as solved.
I just want to confirm if your issue has resolved itself? I tried to use the link you have provided https://fights.today/test-vote/index.html to test however I am getting a 404 Not Found

Do let me know if you require further assistance.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.