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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T06:44:39+00:00 2026-06-17T06:44:39+00:00

This is the jquery ajax part in which i have sent json data to

  • 0

This is the jquery ajax part in which i have sent json data to the php file.

$(function () {
 $('form').submit(function () {
   var fields = $(this).serializeArray();
   var ans_json = JSON.stringify(fields);
   console.log(ans_json);

   $.ajax({
     url: "results.php",
     type: "POST",
     data: ans_json,
     dataType: "json",
     success: function (result) {
       console.log(result);
     }
   });
   return false;
 });
});

Now i want to use this json data sent to the php page.How can i do it? I have done it this way but it returns null.

<?php
   echo json_decode('ans_json');
?>

I have a set of 10 questions which need to be answered. 3 questions were answered so got the below result.This is what i got in my console.

 [{"name":"answer_9","value":"a"},{"name":"answer_10","value":"a"}] quizzes.php:14

null

  • 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-17T06:44:40+00:00Added an answer on June 17, 2026 at 6:44 am

    You don’t need to decode any JSON string at server-side if you encode properly your parameters.

    You can use .serialize() to do the form serialization for you, and it’s ready to send.

    $(function () {
      $('form').submit(function () {
        var serialized = $(this).serialize();
    
        $.ajax({
          url: "results.php",
          type: "POST",
          data: serialized,
          ...
        });
    
        return false;
      });
    });
    

    Your parameters will be available in your $_POST as in any normal POST request. For example,

    $ninth_answer = $_POST["answer_9"];
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a servlet to which I am posting data from ajax(jquery) call. $('form').submit(function()
I have a jQuery AJAX function like this: $.ajax({ url: 'crud/clients.php', dataType: 'json', type:
I have this jQuery code: $(document).ready(function() { $.ajax({ url: pages/+page+.php, cache: false }).done(function( html
I have some jQuery code similar to this: var refreshStuff = setInterval(function() { $.ajax({
When using jQuery 's ajax method to submit form data, what is the best
I have a php page which includes jQuery and a script.js file. When I
I'm loading part of my webpage using AJAX, in particular jQuery.load() . With this
I am loading feed-items into a ul using this jQuery .ajax() call, which I
It seems that i cannot access $(this) inside jquery ajax success function. please see
On document ready I run this code: jQuery(document).ready(function(){ jQuery('#button').click(function() { jQuery('#contact_form').load(/Users/mge/Downloads/jquery-ajax-1/readme.txt); return false; });

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.