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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T23:43:39+00:00 2026-05-31T23:43:39+00:00

I have form and I want to send values from it with ajax to

  • 0

I have form and I want to send values from it with ajax to php script, but it doesn’t send value of chceckbox if is it checked and doesnt’t send file with avatar. So form send only values from text inputs, but not from checkbox and file. Can you help me please what is wrong?
Form:

<form action='' id='form1' method='post' name='form1' ENCTYPE='multipart/form-data'>
<input type='text' name='name' id='name' value=''>
<input type='text' name='age' id='age' value=''>
<input type='text' name='hobby' id='age' hobby=''>
<input type="checkbox" name="chkPHP" id="chkPHP" value="checked">
<input type='file' name='avatar' id='avatar' value='insert avatar' SIZE='30' accept=''>
<input type='submit' name='submit' id='submit' value='submit'>
</form>

Script to send values from form:

<script src="jquery.js" type="text/javascript" charset="utf-8"></script>
<script>
$(document).ready(function(){
    $('#submit').click(function() {

        $('#waiting').show(0);
        $('#form1');
        $('#error').hide(0);

        $.ajax({
            type : 'POST',
            url : 'pksZpacuj.php',
            dataType : 'json',
            data: {
                name: $('#name').val(),
                age: $('#age').val(),
                hobby: $('#hobby').val(),
                chkPHP: $('#chkPHP').val(),
                avatar: $('#avatar').val()
            },
            success : function(data){
                $('#waiting').hide(0);
                $('#error').removeClass().addClass((data.error === true) ? 'error' : 'success')
                    .html(data.msg).show(0);
                if (data.error === true)
                    $('#form1');
            },
            error : function(XMLHttpRequest, textStatus, errorThrown) {
                $('#waiting').hide(0);
                $('#error').removeClass().addClass('error')
                    .text('There was an error.').show(0);
                $('#form1');
            }
        });

        return false;
    });
});  
</script> 
  • 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-31T23:43:41+00:00Added an answer on May 31, 2026 at 11:43 pm

    Uploading files via AJAX is quite hard, and won’t work in all browsers. I would strongly recommend against it.

    If you really want to, you could follow this great post: http://net.tutsplus.com/tutorials/javascript-ajax/uploading-files-with-ajax/

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

Sidebar

Related Questions

I have a contact form i want to use Ajax for. My contact.php script
I have this form. Basically what I want is to send a auto-response with
I want to send the form data to server-side. I have two ways: Normal
i have a form and want to submit it with a script. i'm going
I have a Main form.I want to launch another form from it and launch
I have ajax code like this which is passing form data into createfinalinvoice.php. serial_number
I have Ajax file in which code has written to accept values form user
I need to obtain postdata from a form and send it via ajax .
i am trying to send email from php i have one php file with
I have a simple form as <form method=post action=target.php> <input class=button type=submit value=Submit />

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.