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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T07:25:32+00:00 2026-05-12T07:25:32+00:00

Currently I am working on a ajax-based web application that does some XHR. I

  • 0

Currently I am working on a ajax-based web application that does some XHR.

I chose CakePHP + jQuery to do the jobs, they work pretty well except this little problem.

Say, I make a String of a valid JSON form ==> { “test” : “hello world”}

Then I am calling jQuery’s ajax method to send it to the destination php page:

jQuery.ajax
    ({
        type: 'POST',
        cache: false,
        async: false,
        timeout: 10000,
        url : 'http://localhost/method/',
        dataType : 'json',  //defines expected response datatype
        contentType : 'application/json', //defines request datatype
        data : { "test" : "hello world"},
        success : function(json)
        {
           //do some stuff here.
        }});

Previously I tried this ajax function with empty data (i.e. just use data : {} since this is a POST), and it worked just fine; however, now that I’ve added a json-formatted data to the HTTP POST, is there a way to refer to it from the PHP script’s side?

I tried : data : { "data" : {"test" : "helloworld"}}

I use PHP’s isset[$_POST[‘data’] to check, and the result is POST variable ‘data’ is unset.

Can anyone give me a way to solve this problem? Many thanks in advance!!!

  • 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-12T07:25:33+00:00Added an answer on May 12, 2026 at 7:25 am

    This may be what you are after (from http://www.factsandpeople.com/facts-mainmenu-5/26-html-and-javascript/89-jquery-ajax-json-and-php):

    $(document).ready(function(){ 
      var data = 
      { 
        "sales": [ 
          { "firstname" : "John", "lastname" : "Brown" },
          { "firstname" : "Marc", "lastname" : "Johnson" }
        ] // end of sales array
      }
      var dataString = JSON.stringify(data);
      $.post('simpleformSubmit.php', { data: dataString}, showResult, "text");
    });
    

    The PHP script (Post data contains a json structure):

    <?php
      $logFile = 'logFile';
      $res = json_decode(stripslashes($_POST['data']), true);
    
      echo "sales1_lastname: ".$res['sales'][1]['lastname'];
    ?>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

The web-based application I’m currently working on is growing arms and legs! It’s basically
I am currently working on rails3 application that uses jQuery. I have a javascript
The system I am currently working on requires some role-based security, which is well
I am working on a web application (ASP.NET) game that would consist of a
I'm working with the ChemAxon JChem cheminformatics application to develop a web-based browsable and
I have a web application that fetches a lot of content via ajax. For
I am currently working on some prototypes for a web site I am wanting
I'm currently working on an application that needs to use Windows and Forms authentication
I'm currently working on a site that uses ajax to load the content into
I'm currently working on creating a new C# project that needs to interact with

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.