I'm making a certain ajax request to a java serverlet in the following manner :
var request = $.ajax({
type: "POST",
url: MY_SERVERLET_URL,
data: MY_DATA,
dataType: 'json',
});
request.done(function(msg) {
if (msg.hasOwnProperty("status")) {
var jsonObject = msg["status"].toString();
if (jsonObject == "success") {
// GET RELEVANT URL AND DATA FROM JSON OBJECT AND REDIRECT TO
// THE URL WITH DATA ATTACHED FROM JAVASCRIPT
}
else {
// ERROR
}
}
else {
// ERROR
}
});
request.fail(function(jqXHR, textStatus) {
alert("Error : " + textStatus);
});
What I have Done
Currently the Java serverlet completes its work and returns a certain URL
and a set of data inside a JSON Object to the ajax request, where the ajax request in turn will parse that data and make a certain POST request to the specified url.
What I Want To Do
I want to do this without returning the data to the client side, meaning to make the request from the Java serverlet directly to the the url
but the ajax request from the client side should also follow that request. (The user should be redirected to the specified URL)