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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T00:36:23+00:00 2026-05-30T00:36:23+00:00

I am trying to allow users to save progress by saving an array of

  • 0

I am trying to allow users to save progress by saving an array of data to a file. I know I can force a php download by changing the headers, but I am calling the php script with an ajax call that needs a response to re-enable a button.The reason I neeed to disable the button in the first place is jquery has to gather ALOT of data to send to the script and it takes a couple of seconds to do. I have posted my code below which just saves a local file. Ideally I would just like a “save to” dialog and let ajax know it wen ok.

So could I force a download and still echo back the json data response?

Thank you once again,
Todd

require_once('../FirePHPCore/fb.php');
session_start();

/* Initialize an ajax pessimistic response object. */
$ResponseData = array
(
    'Success' => false,
    'Message' => 'There was an error saving your chart right now. Please try again later.'
);

// assemble the final array to save to disk 
$finalArray                   = array();
$finalArray['colorChart']     = $_POST['colorChart'];
$finalArray['threadBrand']    = $_POST['threadBrand'];
$finalArray['chartName']      = $_POST['chartName'];
$finalArray['stitchChart']    = $_POST['stitchChart'];

file_put_contents('array.txt', serialize($finalArray));

$ResponseData['Success'] = true;
$ResponseData['Message'] = 'Saved.';
/* Output the response data in JSON. */
echo json_encode($ResponseData);
  • 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-05-30T00:36:24+00:00Added an answer on May 30, 2026 at 12:36 am

    Your AJAX call can have PHP prepare the file for download, then return the filename of the temporary file.

    Then, the JavaScript can redirect the browser to the temporary file. If appropriate headers are set, the file will be downloaded and the browser window remains unchanged.

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

Sidebar

Related Questions

I'm trying to allow users to upload files through a PHP website. Since all
Im trying to allow users to login to a website by verifying if they
I'm working on a forums system. I'm trying to allow users to see the
I'm trying to create a basic system that will allow only specific users to
I'm trying to craete a site which allows users to upload any file type
I am trying to make a php login page that allows users to access
I am trying to allow users to enter Hebrew characters into certain fields in
I am trying to create a form to allow users to change their password:
I am trying to save a file using GetSaveFileName and want to have a
I am trying to use Ajax to allow a user to save information (display

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.