I have a brilliant idea for creating something amazing, but I'm uncertain if it's feasible. Here is a basic example of an ajax function that could potentially establish a connection with a server...
function getFakePage(userId)
{
var ajaxObject, path, params;
ajaxObject = getAjaxObject();
params = "?userId=" + userId
path = getInternalPath() + "someServlet" + params;
ajaxObject.open("GET", path, true);
ajaxObject.send();
// Additional code for ready state change here
}
Picture this scenario...
https://localhost:8443/Instride/user/1/admin
Now, suppose I want to utilize JavaScript to redirect the user to the above URL. Typically, one would simply do this...
window.location = "https://localhost:8443/Instride/user/1/admin";
However, I have an innovative concept to develop a JavaScript function (without using JS frameworks) that could seamlessly blend the ajax and window.location codes. Essentially, I aim to create a connection with the server through ajax, transmit a specified URL to a servlet on the server, and then redirect the user to that URL. This way, while the user is connecting to my server from any location worldwide, they will see a loading icon instead of a blank white page.
Therefore, to clarify my objective: I do not wish to include window.location within the success of my ajax function (to avoid two round trips), nor do I intend to return a large HTML chunk for the requested resource and append it to the page. My goal is to establish a server connection via ajax, send the desired URL to a servlet, and find a way to direct the user accordingly. Is this even achievable?
I understand that some may find this concept unconventional, but it holds significance especially for international users with slow internet connections experiencing prolonged loading times. If this idea is plausible, I would greatly appreciate any insights or advice. Thank you very much!