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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T11:59:35+00:00 2026-06-01T11:59:35+00:00

Hi I want to send data to the server and then have the php

  • 0

Hi I want to send data to the server and then have the php file save it.
But currently I can’t get even a simple POST to work.

This is the javascript and html part:
This function is declared in the head:

function sendTableToServer(){
    var xhttp;
    if (window.XMLHttpRequest){
        xhttp=new XMLHttpRequest();
    } else {
        xhttp=new ActiveXObject("Microsoft.XMLHTTP");
    }

    xhttp.open("POST","http://music.collwyncraig.info/hajimama/save_setlist.php",true);
    xhttp.setRequestHeader("Content-type","application/x-www-form-urlencoded");
    xhttp.send("fsong=AbandonSeoul");
}

Then this html is in the body:

<button type="button" onclick="sendTableToServer()">Save Setlist</button>

This is the php file

<?php
if (isset($_POST["fsong"])){
    echo 'trying';
    $song = $_POST["fsong"]; 
    echo $song;
    echo 'ok';
}
?>

When I click the button, nothing happens.
If I use a <form> and a submit button, the php file is loaded by the browser, and I can access the input. However, I want to use a function like this because the information I want to send is going to be taken out of the html page using javascript and HTML DOM.
So, why doesn’t anything happen? 🙂

  • 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-01T11:59:36+00:00Added an answer on June 1, 2026 at 11:59 am

    If you want the same behavior as a form except you want to get data from the page, just create a form and submit it:

    var form = document.createElement('form');
    form.action = 'http://www.example.com/do-something';
    form.method = 'post';
    var song = document.createElement('input');
    song.type = 'hidden';
    song.name = 'song';
    song.value = 'Song Name';
    form.appendChild(song);
    form.submit();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to send the form data to server-side. I have two ways: Normal
Hello Sir i want send list of data to php server i use following
I want that user/attacker to encrypt the data and send to server. Now I
I created the list that have device detected, and I want to send data
I want to make a simple HTTPRequest to a php script and I have
I am using Ajax to send query to PHP server, which then run the
Hi I want to send a fixed amount of data (say 5MB) from server
I want my server app to be able to send data to be processed
In Java, if I want to send data to form on the server, where
I want to send data to my web server while the app is closed.

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.