I need to create in either Javascript or jQuery an http request. In it I need to put some header fields and then send this all to an external url that is on the same server. The target web page needs to read these headers. In short, I need to make a sort of redirect, but which contains header parameters provided. I am trying to do it in the flowing way but it does not redirect:
var mdata = {roles: roles};
$.ajax({
url: "SendRequest",
type: "POST",
data: mdata,
//crossDomain: true,
dataType: "json"
})
.done(function (data) {
$.ajax({
url: "/OimPortalEmulation",
type: "POST",
beforeSend: function(xhr){xhr.setRequestHeader('name', 'Salvo'); xhr.setRequestHeader('groups', data)}
}).done(function(){})
.fail(function(){alert('Redirect Failed!')});
})
.fail(function (data) {
alert("ajax error! ");
})
.always(function () {
});
This works in as much as it calls the target servlet which prints out successfully the header provided, but it does no open a new tab nor does it show the pag in the current tab. How can I resolve this?
FYI: I am using Java Servlets on the server side.
Edit: I provided further details on the problem posted.