SendNUIMessage does not trigger "message" event on NUI

Hello, I’m trying to listen for message events on my NUI but when the event should trigger my message event listener doesn’t get triggered.

The “openPhone” net event is triggered by item use.

client/client.lua

RegisterNetEvent("openPhone",function(name) -- The event name is simplified for readability in topic
	if not PhoneStatus then 
		SetNuiFocusKeepInput(true)
		SetNuiFocus(true,true)
		SendNUIMessage({ nuimessage = 'open', name = name })
		DoPhoneAnimationHacker('cellphone_text_in')
		Wait(250)
		newPhonePropHacker()
		PhoneStatus = true
	end
end)

Everything but the NUI message in this net event is being triggered (I don’t know if the problem is client or NUI sided. So the SendNUIMessage might be working so my NUI event handlers might be the problem).

nui/assets/js/fivem.js (using jquery)

$(window).on("message", function (e) {
	const data = e.data;
	console.log(JSON.stringify(data)); // This is not being printed to FiveM Console (F8)
	console.log("hello"); // This is not being printed to FiveM Console (F8)
	switch (data.nuimessage) {
		case "open":
			openPhone();
			break;
	}
});

My console logs aren’t being printed in the FiveM Console (F8). When I checked on my browser if the event listener was registered, I was able to see the ‘message’ event listener registered.
(the function ‘openPhone’ is declared)
(I also tried without jquery but it doesn’t make a differance)

nui/ui.html

        ...

        <!-- Scripts -->
		<script src="../config.js"></script>
		<script src="assets/js/terminal.js"></script>
		<script src="assets/js/option.js"></script>
		<script src="assets/js/menu.js"></script>
		<script src="assets/js/fivem.js"></script>
	</body>
</html>

There is no other ‘message’ event listeners on my other scripts.

fxmanifest.lua

fx_version 'cerulean'
game 'gta5' 

author '...'
description '...'
version '1.0.0'
ui_page 'nui/ui.html'

files { 
		'config.js',
		'nui/ui.html',
		'nui/assets/icons/*.png',
		'nui/assets/icons/active/*.png',
		'nui/assets/icons/inactive/*.png',
		'nui/assets/css/*.css',
		'nui/assets/js/*.js',
}
	
client_scripts {'client/**/*'}
server_script 'server/server.lua'

lua54 'yes'

Does anyone know what’s wrong?