Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8956079
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T14:42:26+00:00 2026-06-15T14:42:26+00:00

I can pass a parameter for the redirect url and a user id in

  • 0

I can pass a parameter for the redirect url and a user id in a browser, this is an intranet application btw. So you can paste the address such as “http://intranetapp?redirect_url=http://crapola&userid=xxxxxxx. It redirects you to that url and provides additional information for the user id, which is what i want to obtain for several hundred users. The information is returned as part of parameters where you get redirected. Is there any way to call (GET request) this with ajax or related method of jquery and read the returned url and parameters instead of just getting the returned html?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T14:42:27+00:00Added an answer on June 15, 2026 at 2:42 pm

    Chris, if I understand correctly, what you want to do is moderately tricky.

    I have never needed to do this sort of thing but know in principle that it involves an unusual type of ajax request – namely a “HEAD” request, allowing the redirect url (and other meta data) to be inspected without receiving the main part of the HTTP response (the body).

    Your intranet server should handle HEAD requests (they are at least as safe as GETs) but not necessarily. If not, then have a word with your server admins. If you are the server admin then have a root around in the httpd.conf file and/or the appropriate .htaccess file (assuming Apache).

    As with all types of ajax, the code is also tricky because parts of it need to run asynchronously (when an HTTP response from the server arrives back). To assist in this, jQuery’s Deferreds/Promises can be (liberally) employed.

    Your main worker function (still if I understand correctly) will be something like this :

    function getUserParams(userID) {
        var $ = jQuery,
            dfrd = $.Deferred(),
            q = {},
            baseURL = 'http://intranetapp?redirect_url=http://crapola&userid=';
        $.ajax({
            type: "HEAD",
            url: baseURL + userID,
            cache: false,
            success: function(data, textStatus, jqXHR) {
                var location = jqXHR.getResponseHeader('Location');
                if(location){
                    var search = $("<a>").attr('href', location).get(0).search.replace(/^[?]/, ''),
                        prop, pair;
                    if (search) {
                        $.each(search.split("&"), function(i, arg) {
                            pair = arg.split("=");
                            if (pair.length >= 1) {
                                prop = pair.shift();
                                q[prop] = (pair.length == 1) ? pair[0] : (pair.length > 1) ? pair.join('=') : '';
                            }
                        });
                    }
                    //At this point q is a hash representing parameters in the location's search string.
                    dfrd.resolve(userID, q);
                }
                else {
                    dfrd.reject(userID, 'No redirect url in the response');
                }
            },
            error: function(jqXHR, textStatus, errorThrown) {
                dfrd.reject(userID, 'Ajax failure: ' + textStatus + ': ' + errorThrown);
            }
        });
        return dfrd.promise();
    }
    

    Note that, because the ajax is asynchronous, we return a promise not the results we actually want; they arrive later, packaged in the javascript plain object q.

    Here’s how to test getUserParams() :

    var userID = '12345678';
    getUserParams(userID).done(function(userID, q) {
        //Work with userID and q as required
        console.log(['Success', userID, q.fullname, q.status, q.postalcode].join(': '));//for example
    }).fail(function(userID, message) {
        //Handle error case here
        message = message || ''; 
        console.log(['Error', userID, message].join(': '));//for example
    });
    

    Your intended use, with hundreds of urls, will be something like this :

    var userIDs = [
        //array of userIDs (hard coded or otherwise constructed)
        '1234',
        '5678'
    ];
    var promises = [];
    $.each(userIDs, function(i, userID) {
        var p = getUserParams(userID).done(function(userID, q) {
            //work with userID and q as required
            $("<p/>").text([userID, q.fullname, q.status, q.postalcode].join(': ')).appendTo($("#results"));//for example
        }).fail(function(userID, message) {
            //handle error case here
            message = message || ''; 
            console.log(['Error', userID, message].join(': '));//for example
        });
        promises.push(p);
    });
    

    You may also want to do something when responses to ALL ajax requests have been received. If so then the additional code will look like this :

    $.when.apply(null, promises).done(function() {
        //Do whatever is required here when ALL ajax requests have successfully responsed.
        //Note: any single ajax failure will cause this action *not to happen*
        //alert('All user data was gathered');
        console.log('All user data was gathered');
    }).fail(function() {
        //Do whatever is required here when ALL ajax requests have responsed.
        //Note: any single ajax failure will cause this action *to happen*
        //alert('At least one set of user data failed');
        console.log('At least one ajax request for user data failed');
    }).then(function() {
        //Do whatever is required here when ALL ajax requests have responsed.
        //Note: This function will fire after either the done or fail function.
        //alert('Gathering of user data complete, but not necessarily successfully');
        console.log('Gathering of user data complete, but not necessarily successfully');
    });
    

    Part tested (the code runs but I don’t have the means to test the redirect or handling of the Location header).

    You will need to fine-tune [some subset of] the code to make precise use of the user data in the q object, and to handle errors appropriately.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to pass additional parameter to redirect url when the user accept fb
How to custmoize a UIview with two UIbutton where user can pass parameter to
I see that with SQL Server 2005 you can pass a parameter as numeric
How can I pass a parameter from batch to vbscript? My batch script sends
How can I pass the Parameter to a function. for example public void GridViewColumns(params
Possible Duplicate: How can I pass a parameter to a setTimeout() callback? Is there
I am trying to pass the parameter, which is 'priceValue'. How can I pass
How can I pass the classunloading parameter to mvn? mvn -XX:+CMSClassUnloadingEnabled exec:java -Dexec.mainClass=Test Whats
How can I pass a request parameter to fr-workflow-send-submission in persistence-model.xml? For example if
How can I pass an optional parameter to the flash message? I'm using Twitter

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.