jQuery open page in a new tab while passing POST data

jQuery open page in a new tab while passing POST data

  1. Blog
  2. 15 November 2026
  3. 5 min read

Stefan Bogdanescu

Founder & Senior Architect

The Fundamental Limitation: Why You Can't POST and Open in a New Tab Simultaneously

It is a common misconception that you can simply fire an AJAX request to send data and then immediately redirect the browser window to the destination URL, expecting the new tab to receive the payload. If your goal is to open datadestination.php in a new tab while ensuring it contains the contents of your list variable via a POST request, you are running into a hard boundary in how browsers handle navigation and the HTTP protocol.

When you execute jQuery.post('datadestination.php', list), the browser initiates an asynchronous network transaction. The current document remains active, the address bar does not change, and the data is transmitted over the wire without ever navigating away from the original page. You are effectively building a wall between the client and the server's response. If you attempt to open a new tab using window.open immediately after this call, or even within the same line, you are creating two distinct contexts. The first context (the current tab) has already finished its request cycle before the second context (the new tab) is born.

The core issue is that a standard hyperlink or a window.location assignment triggers an HTTP GET request by default. When the user clicks a link, the browser requests the resource specified in the URL. It does not automatically append the parameters from a previous AJAX call to that request as POST data. The new tab loads exactly what the URL string dictates: a GET request for datadestination.php. The data you sent via jQuery.post stays trapped inside the first tab's memory and network buffer.

To achieve your goal, you must abandon the expectation of a single atomic action where one click sends a POST and opens a tab simultaneously. Instead, you need to decouple the data transmission from the navigation event.

The most straightforward implementation involves triggering the POST request on the server side to prepare the data, or restructuring how the destination page accepts input. However, if your requirement is strictly client-side—sending specific list data and opening a new tab that holds it via POST—you are facing architectural constraints that standard JavaScript cannot bypass without server intervention.

The Server-Side Bridge Pattern

The only robust way to solve this problem is to have the server handle the transition. Here is how the logic should flow:

  1. Current Tab: Execute jQuery.post. This sends the list data to a specific endpoint (e.g., /api/prepare).
  2. Server Response: The server receives the POST, processes the list, and generates a URL that includes the data in the query string or session storage, effectively "locking" the data into the state of the application.
  3. Navigation: Once the server confirms receipt, you trigger window.open('datadestination.php?token=xyz').

In this scenario, the new tab opens via a GET request (which browsers support natively for navigation), but the destination page reads the token or session state and reconstructs the data internally. You cannot force a browser to issue a POST request when opening a new tab via window.open using a standard URL string.

The Invisible Form Misconception

Many developers attempt to solve this by dynamically creating a form element, populating it with the list data, setting its action to the destination URL, and submitting it without page reload. While this works for the same tab (triggering a full page POST), it fails when trying to open in a new tab. When you submit a form, the browser follows the HTTP redirect or completes the request on the current document context. You cannot use a standard <form> submission to initiate a cross-tab POST navigation because the target="_blank" attribute applies to the link that triggers the load, not the submission mechanism itself.

The Laravel Company Approach

If you are building this application using Laravel, there is a cleaner pattern available that leverages server-side state management rather than fighting browser limitations. You can utilize Laravel's session handling or a dedicated API endpoint to store the list data temporarily.

In your current controller, handle the POST request from jQuery:

// routes/web.php or controller method
public function processList(Request $request) {
    // Validate and store the 'list' data in session or DB
    $data = json_decode($request->getContent(), true);
    
    // Store a unique token associated with this data
    $token = hash('sha256', json_encode($data));
    Session::put('temp_list_data', $data);
    Session::put('token', $token);
    
    // Return the destination URL with the token
    return response()->json([
        'url' => route('datadestination.show', ['token' => $token])
    ]);
}

On your JavaScript side, you would do this:

jQuery.post('/api/process-list', { list: listData })
    .done(function(response) {
        // Open the new tab with the token
        window.open(response.url, '_blank');
    });

This approach ensures that when the new tab opens datadestination.php, the server can retrieve the original list data from the session using the token. The new tab performs a GET request (standard behavior), but the content of the page is derived from the POST data you originally sent.

Why Direct POST Navigation Fails

Attempting to use window.open('datadestination.php', '_blank') after a jQuery.post call will result in a 405 Method Not Allowed error if the server strictly expects a GET request for that route, or it will simply load an empty page if the server ignores the missing parameters. The browser never sends POST data as part of the URL hash or query string during navigation unless explicitly encoded by the developer.

If you require the new tab to actually send a POST request to datadestination.php upon opening, the link itself must be generated with a form submission target. However, standard browsers do not allow window.open to initiate a POST request directly from a URL string; they only support GET for navigation.

Final Recommendation

You cannot simply "pass" POST data to a new tab via window.open. The solution lies in shifting the payload storage to the server. By using a token-based approach or session storage triggered by the initial jQuery.post, you can open the new tab successfully and ensure the destination page has access to your list variable without violating browser security models regarding cross-origin POST restrictions and navigation history.

Our network