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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T09:21:00+00:00 2026-06-12T09:21:00+00:00

have another question, to do with ajax and how to send data from a

  • 0

have another question, to do with ajax and how to send data from a checkbox form without any page reload/redirect, i have the following code, here’s the markup:

 <html>
   <head>
      <title>guild</title>
   </head>
   <body>
      <div id="dive">
         <form method="post" action="">
            <input type="checkbox" name="userList[]" value="together" />together<br />
            <input type="checkbox" name="userList[]" value="we" />we<br />
            <input type="checkbox" name="userList[]" value="made" />made<br />
            <input type="checkbox" name="userList[]" value="it" />it<br />
            <input type="submit" id="submit" value="yeah we did it!" />
         </form>
      </div>
      and here's the jquery:
      <script type="text/javascript" src="jquery-1.8.0.min (1).js"></script>
      <script type="text/javascript">
         $(document).ready(function(){
         //when the button is clicked
         $("#submit").click(function(){
         //put the checked data into an array
         var userList= $('#dive input[type=checkbox]:checked').serializeArray();
         //send the data without page reload/refresh/redirect
         $.post("guild.php", {userList: userList},function(userList)
         {
         });
         });
         });
      </script>
   </body>
</html>

so the checked data is supposed to be sent to a php file which writes it to a file, here’s the script:

<?php
//get sent data
$userList=$_POST['userList'];
//open file to be written to
$fp=fopen("guild.html", 'a');
//write data into file
for($i=0;$i<sizeof($userList);$i++) 
{
fwrite($fp, "<div class='gn'>."userList[$i]"."<br>"."</div>");
}
//close file
fclose($fp);
?>

i know that this is a very simple question, but i just can’t get it to work, even after reading other answers. i need the checked data to be sent in form of an array, not a string. so how would i change the jquery part to make it work?thanks in advance for the help, i am an extreme beginner!

  • 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-12T09:21:01+00:00Added an answer on June 12, 2026 at 9:21 am

    According to the jQuery post documentation, you should be sending the post data array like so:

    $.post("guild.php", { "userList[]": userList }...
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this code (found from another StackOverflow question: $(document).ready(function() { $.ajax({ url: soundfile.mp3,
I have put a form on a web page where the user can send
i have another question on getting my XML serialization neat, which i can't seem
I have another question :(. I'm trying to download multiple files for my application.
I have another question and I can't seem to find anything on Google. What
Okay, so I have another question on a prolog homework problem I am struggling
I have another simple question about Node. I'm trying to make a simple http
I have another Richfaces question which may seem rather weird. I am developing a
i have another (probably unanswered) question about map views. I have a map view
I have recently posted another question which straight away users pointed me in the

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.