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 8723811
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T07:42:20+00:00 2026-06-13T07:42:20+00:00

I have a php function in which some pdf is being created. I have

  • 0

I have a php function in which some pdf is being created. I have a button and I want to call that function on button click and then redirecting to a url. What can be the simplest method of doing that?

  • 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-13T07:42:21+00:00Added an answer on June 13, 2026 at 7:42 am

    If you need to call a PHP method, I’d use AJAX. Something like this:

    var btn = document.getElementById("button_id");
    
    btn.onclick = function () {
        // Make AJAX request
        // On success, do this:
        window.location.href = "url to redirect to";
    };
    

    The code for “Make AJAX request” can be Googled easily, and I will provide it in a minute 🙂

    UPDATE:

    function ajaxFunction() {
        var ajaxRequest; // The variable that makes Ajax possible!
    
        try {
            // Firefox, Chrome, Opera 8.0+, Safari
            ajaxRequest = new XMLHttpRequest();
        } catch (e) {
            // Internet Explorer Browsers
            try {
                ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP");
            } catch (e) {
                try {
                    ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP");
                } catch (e) {
                    try {
                        ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP.6.0");
                    } catch (e) {
                        try {
                            ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP.3.0");
                        } catch (e) {
                            throw new Error("This browser does not support XMLHttpRequest.");
                        }
                    }
                }
            }
        }
        return ajaxRequest;
    }
    

    The AJAX code –

    var req = ajaxFunction();
    req.onreadystatechange = function (response) {
        if (response.status == 200 && response.readyState == 4) {
            window.location.href = "url to redirect to";
        }
    }
    req.open("POST", "your PHP file's URL", true);
    req.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
    req.send(null);    // Or send any `key=value&` pairs as a string
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following function in a PHP script, which returns and API call:
I have this php function, which I want to convert to javascript function, but
Does PHP have some kind of function that will compare the numbers? I know
I have a php file that contains class which runs some lengthy database operations.
I've written some code which created reports and then exports it to .PDF using
I have a PHP script that loads a function which uses Curl to log
I have a jQuery call to some PHP which works fine. What I would
I have a php function which returns JSON in response to a ajax request
i have a php function which returns a random json encoded color <?php function
I have a PHP function which inserts multiple records into MySQL: function commit_purchase($asset_type_ID, $org_ID,

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.