Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

197
Views
Create an HTTP request, give it a header and open url in a new tab

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.

over 4 years ago · Santiago Trujillo
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!