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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T23:19:52+00:00 2026-06-13T23:19:52+00:00

I have this ajax form, which at the end I have the values in

  • 0

I have this ajax form, which at the end I have the values in an array. the code is below..but i keep getting null in my php response for these items. I think I am doing this .ajax call wrong, any ideas would be greatly helpful. I also dont know what to write in the success section of the .ajax call. is that what I am missing? Please have a look below:

$('#submit_third').click(function(){
    //update progress bar
    $('#progress_text').html('100% Complete');
    $('#progress').css('width','339px');
    //prepare the fourth step

   var fields = new Array(
        $('#usernameReg').val(),
        $('#passwordReg').val(),
        $('#email').val(),
        $('#firstname').val(), 
        $('#lastname').val(),
        $('#city').val(),
        $('#phone').val(),
        categoryResult,
        $("#msg").val()                     
    );

    var tr = $('#fourth_step tr');
    tr.each(function(){
        //alert( fields[$(this).index()] )
        $(this).children('td:nth-child(2)').html(fields[$(this).index()]);
    });


    //slide steps
    $('#third_step').fadeOut(1000);
    $('#fourth_step').delay(1000).fadeIn(1000);          

    $('#submit_fourth').click(function(){
        //send information to server
        console.log(fields);
       $.ajax({
            type: "POST",
            data: 'fields',
            dataType: 'json',
            url: "php/postEngine.php",
            success: function(html){

            }
        });


    });     
});

php info (i am using flourish:

include_once($_SERVER['DOCUMENT_ROOT'] . '/../inc/init.php');
include_once($_SERVER['DOCUMENT_ROOT'] . '/dev/form_data.php');
include_once($_SERVER['DOCUMENT_ROOT'] . '/dev/db_handling.php');
ini_set('display_errors', 'On');
try {

    $tbl_user   =   'tbl_users';

    $statement = $db->prepare("INSERT INTO $tbl_user 
        (username,
        email,
        firstname,
        lastname,
        city,
        phone)
        VALUES 
        (%s,
        %s,
        %s,
        %s,
        %s,
        %s
        )"
    );

    $db->query($statement,
        $un,
        $email,
        $firstname,
        $lastname,
        $city,
        $phone
        );

    //  Update of Email_Replied to 1

    //$db->execute("UPDATE accommodation SET Email_Replied = '1' WHERE ID = %i", $user_id); 

} catch (Exception $e) {
    echo $error_msg;
    echo $un;
    echo $email;
    echo $firstname;
    echo $lastname;
    echo $city;
    echo $phone;
    echo json_encode($un);
    $error_msg = 'An error occured on postEngine.php';

}

?>

$un         =   fRequest::get('fields[0]');
$email      =   fRequest::get('fields[2]');
$firstname  =   fRequest::get('fields[3]');
$lastname   =   fRequest::get('fields[4]');
$city       =   fRequest::get('fields[5]');
$phone      =   fRequest::get('fields[6]');

?>

  • 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-13T23:19:53+00:00Added an answer on June 13, 2026 at 11:19 pm

    It should be :

    data: fields,
    

    not

    data: 'fields',
    

    right now all you’re doing is sending the string ‘fields’ to the server, not the variable fields ?

    Also make sure you’re expecting an array on the server, and JSON back to the client etc. as you have specified JSON in the dataType, but in your success function you’re calling it HTML, which it is not, not that it would matter as html is just a variable, but it does look like you’re not expecting JSON, but still expecting JSON, and when the dataType is set to JSON, any response containing non valid JSON (like HTML) will fail ?

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

Sidebar

Related Questions

I have an ajax form in asp.net mvc which is as simple as this:
I have this AJAX code, but it doesn't seem to throw the 'alert' method.
i have code like this. which is actually a form .which lets user updates
I have this ajax jquery code: var form = document.getElementById('frm'); var data_string = form.serialize();
I have this AJAX submission form written with the jQuery validation plugin. It all
I have a form and when this form is sent via AJAX, I display
I have form in my page, I am using ajax.beginform(). Inside this form I
I have a form element which is being pulled in on request with ajax.
So I have this form which requests a JS call when a comment is
I have the following JQuery to submit a contact form with jquery ajax. This

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.