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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T23:51:47+00:00 2026-05-14T23:51:47+00:00

I have a function in javascript called dumpData which I call from a button

  • 0

I have a function in javascript called "dumpData" which I call from a button on an html page as **onlick="dumpData(dbControl);"* What it does is return an xml file of the settings (to an alert box right now). I want to return it to the user as a file download. Is there a way to create a button when click will open a file download box and ask the user to save or open it? (sorta of like right-clicking and save target as)…

Or can it be sent to a php file and use export();? Not sure how I would send a long string like that to php and have it simple send it back as a file download.

Dennis

  • 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-14T23:51:48+00:00Added an answer on May 14, 2026 at 11:51 pm

    I eneded up going this route:

    The HTML code

        <script type="text/javascript">
    
            $(document).ready(function() {
    
                $("#save").click(function(e) { openDialog() } );
                });
    
    
        </script>
    
    <button id="save" >Send for processing.</button>
    

    The javascript code:

    function openDialog() {
    
        $("#addEditDialog").dialog("destroy");
        $("#Name").val('');
        $("#addEditDialog").dialog({
            modal: true,
            width: 600,
            zIndex: 3999,
            resizable: false,
            buttons: {
                "Done": function () {
                    var XMLname = $("#Name").val();
                    var XML = dumpXMLDocument(XMLname,geomInfo);
                    var filename = new  Date().getTime();
                    $.get('sendTo.php?' + filename,{'XML':XML}, function() {
                        addListItem(XMLname, filename + ".XML");
                    });
                    $(this).dialog('close');
                },
                "Cancel": function () {
                    $("#Name").val('');
                    $(this).dialog('close');
                    //var XMLname = null;
                }
            }
    
        });
    
        }
    

    PHP Code, I just decided to write the file out to a directory. Since I created the filename in the javascript and passed to PHP, I knew where it was and the filename, so I populated a side panel with a link to the file.

    <?php    
        if(count($_GET)>0)
        {
            $keys = array_keys($_GET);
            // first parameter is a timestamp so good enough for filename    
            $XMLFile = "./data/" . $keys[0]  . ".kml";
            echo $XMLFile; 
            $fh = fopen($XMLFile, 'w');
            $XML = html_entity_decode($_GET["XML"]);
        $XML = str_replace( '\"', '"', $XML );
            fwrite($fh, $XML);
            fclose($fh);        
        }   
        //echo "{'success':true}"; 
        echo "XMLFile: ".$XMLFile;
    ?>
    

    I don’t know why, but when I send the XML to my php file it wrote out the contents withs escape charters on all qoutes and double quotes. So I had to do a str_replace to properly format the xml file. Anyone know why this happens?

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

Sidebar

Related Questions

I have a javascript function from which I need to call a controller action
I'd like to have a javascript function called on page load and unload which
I have a javascript function which is called from another function I have. For
I have a Javascript function that is called from the onchange method in a
Can I´m asking for advice. I have function which should return javascript object function
1) on main page i have javascript function function editSuccess(data) { alert(editSuccess called); }
I have a javascript function called ShowConfirmationBox(). I want to call it in my
In my application, I have a Javascript function which get called after every minute.
why my code is not working? I have called a javascript function after page
I have a javascript function that is called onsubmit: function formCheck(){ return usernameCheck() &&

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.