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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T16:32:25+00:00 2026-06-12T16:32:25+00:00

Ok, I spend many time on this, I don’t get what I’m doing wrong.

  • 0

Ok, I spend many time on this, I don’t get what I’m doing wrong.

It seems impossible to get the data in the PHP file.

  1. First I call many times “copy” to fill the “result” array.
  2. Then, I call the $.ajax method
  3. In the process.php $_POST is empty

–> In the PHP $x, $y or $time or not null but not empty.

Edit 2:

Ok – with json_last_error() i saw that it’s my json which is
“Syntax error: malformed”. But i don’t know how to encode it better than what i’m
doing.

So i cheat by adding a stripslashes() on the $_POST.

[{\”x\”:104,\”y\”:218,\”timestamp\”:1349476537434},{\”x\”:90,\”y\”:202,\”timestamp\”:1349476537469},{\”x\”:82,\”y\”:192,\”timestamp\”:1349476537487},{\”x\”:71,\”y\”:177,\”timestamp\”:1349476537514},{\”x\”:68,\”y\”:174,\”timestamp\”:1349476537568},{\”x\”:68,\”y\”:173,\”timestamp\”:1349476537801},{\”x\”:68,\”y\”:174,\”timestamp\”:1349476538478},{\”x\”:68,\”y\”:175,\”timestamp\”:1349476538512},{\”x\”:68,\”y\”:175,\”timestamp\”:1349476538579},{\”x\”:69,\”y\”:175,\”timestamp\”:1349476538678}]

Edit 1:

The posted data seems to be good (look under), and i finish in the
“success function”.

[{“x”:529,”y”:97,”time”:1349469608703},{“x”:385,”y”:331,”time”:1349469608720},…..]

JS Side – index.php :

<script src="jquery.js"></script>    

results = new Array();

function copy(x, y, time) {
   var o = { 'x': x, 'y': y, 'time': time };
   results.push(o);
}

function save() {
    var encoded_results = JSON.stringify(results);

    $.ajax({
        url: "process.php",
        type: 'POST',
        data: {
            "results" : encoded_results 
        },

        success: function(data, status, xhr) {
           alert(data);
           console.log(data);
           console.log(xhr);
        },      
        error: function (xhr, ajaxOptions, thrownError) {
            alert(xhr.status);
            alert(thrownError);
        }
    });
}

PHP Side – process.php :

if(isset($_POST["results"]))
{
    $result_json = $_POST["results"];
    $JSONArray  = json_decode($result_json, true);

    if($JSONArray !== null)
    { 
        $x = $JSONArray["x"];
        $y = $JSONArray["y"];
        $time = $JSONArray["time"]
    }
}
  • 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-12T16:32:26+00:00Added an answer on June 12, 2026 at 4:32 pm

    On the JavaScript side you are posting an array of objects – a list of x / y / time combinations. The PHP side however ignores the list and object part:

    $x = $JSONArray["x"];
    

    vs.

    $x = $JSONArray[0]->x;
    

    So overall in a loop maybe:

    foreach($JSONArray as $triple)
    {
        $x=$triple->x;
        $y=$triple->y;
        $time=$triple->time;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I spend most of my time plotting data, but unfortunately I haven't found a
Spent many hours and still can't figure that out. sampleData.json file contains the following
Is it ok to send as many number of primitive data as you want
I spend much of my time programming in R or MATLAB. These languages are
I haven't spent a ton of time researching this yet, mostly looking for best
There are many questions on zipping in Delphi, anyway this is not a duplicate.
I'm troubled by this question for a long time now. I work in the
I have an application that shows some data in p:DataTable.... This table is accessible
I spend a lot of time debugging applications in Eclipse using JPDA. There are
What is the best way to get stored procedure useage data on a specific

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.