Working on a search bar that links to the client's catalogue (located at a different URL). The catalogue website has two different IP addresses: local and external. If using on-premise Wi-Fi, the local IP address works but the external doesn't. I need to open whichever IP address is working for a client. It's a WordPress website where I have zero access to anything except their frontend so I'm pretty much stuck with JS.
As of now, I'm opening both links when someone clicks.
window.open(`IP_External?idx=ti&q=${document.getElementById('searchText').value}`, `_blank`);
window.open(`10.1.1.6/search?idx=ti&q=${document.getElementById('searchText').value}`, `_blank`);
I want to check the external IP address. If it works or responds on time (say 5 seconds), that IP address should be used otherwise the local one. How do I do this? I don't mind using JQuery but have never used it before.