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

  • Home
  • SEARCH
  • 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 8836305
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T09:27:57+00:00 2026-06-14T09:27:57+00:00

I am trying to create a button on my chat that will allow someone

  • 0

I am trying to create a button on my chat that will allow someone to print the conversation. So I made the button that runs a PHP script that creates a new file, writes the conversation to file, and also writes the following jQuery.

jQuery AJAX Call

  function OnBeforeUnLoad () {
            $.ajax({
               type: 'GET',
               url: 'deleteFile.php',
               data: {  
                           pageName: ".$pageName."
                     },
               dataType: 'text',
               success: function(data){alert('Good bye 1!');}
            });

            return;
          }

HTML Put into page

<br/><br/><form method="get" action="deleteFile.php"> <input type="submit" value="Close this Window"/> 
             <input type="text" value="'.$pageName.'" name="pageName" style="visibility:hidden"/></form>

deleteFile.php

<?php
$pageName = $_GET['pageName'];
$fullURL = 'PrintPage'.$pageName.'.php';
unlink($fullURL);

echo '<script>window.close();</script>';

?>

When the page shows up and I click the “Close this Window” button it does exactly what I want. It deletes the file and closes the window. But I do not get the same results when I close the window (aka OnBeforeUnLoad()). I even tried triggering submit by giving the form an id of deleteFiles and then doing $(‘#deleteFiles’).submit() and it still didn’t work.

How do I get the AJAX to work within the OnBeforeUnLoad function?

  • 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-14T09:27:58+00:00Added an answer on June 14, 2026 at 9:27 am

    Feel like a dummy…. After making all those changes… I found out all I needed to do was add

    <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
    

    to the header.

    Because I was dynamically creating the page in php, I forgot I needed to readd the jQuery.

    Always the small things.. Thanks everyone for the help.

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

Sidebar

Related Questions

Im trying to create a button that will rotate my animation. I have found
I'm trying to create a button that will hide a div that it is
I'm trying to create a button linked to a text field that will let
trying to create a button that will goto the next option in a selectmenu
I'm trying to create a button that, when clicked will cycle ad nauseum through
I am trying to create a options button above my scroll view that will
I'm trying to create a button that fades out and then in when I
I am trying to create a button that already has an index captures and
I am trying to create a button that can pop up the speech input
I am trying to create a flip button that shows changing content on every

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.