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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T14:37:37+00:00 2026-06-13T14:37:37+00:00

my JS is creating objects that look like this: Now I want to post

  • 0

my JS is creating objects that look like this:

enter image description here

Now I want to post it to a PHP page.

What I tried is this:

var json = JSON.stringify(item_contents);
console.log(json);

jQ.post(
    "http://somedomain.com/headlines/save_items/", 
    json,
    function(data){
        console.log("Data: ");
        console.log(data);
        alert("first success");
    },
    "json"
)
.success(function() { 
    alert("second success"); 
})
.error(function(data) { 
    alert("error: "); 
    console.log(data);
})  
.complete(function() { 
    alert("complete"); 
});

…and the output is always an error. I’m using cakePHP..
Any help? TIA!!!

EDIT:

Currently, what i have on my php page is:

echo print_r($_POST);

and im getting a blank or undefined ouput..

  • 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-13T14:37:40+00:00Added an answer on June 13, 2026 at 2:37 pm

    If you really want to post json, set variable name.

    jQ.post(
        "http://somedomain.com/save_items.php", 
        {json: json}, //<--HERE
        function(data){
            console.log("Data: ");
            console.log(data);
            alert("first success");
        },
        "json"
    )
    .success(function() { 
        alert("second success"); 
    })
    .error(function(data) { 
        alert("error: "); 
        console.log(data);
    })  
    .complete(function() { 
        alert("complete"); 
    });
    

    In php use echo $_POST['json'];

    you also may want to just post object itself:

    jQ.post(url,object,function(data)
               {
                     console.log('success',data);
                }
               ,"json")
                .error(function(data) { 
                    console.log('error',data);
                 });
    

    in php use echo json_encode($_POST);
    be sure that somedomain.com is the same where js is.

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

Sidebar

Related Questions

I have a number of classes that look like this: class Foo(val:BasicData) extends Bar(val)
I have a dictionaries that look like this: s_dates_dict = {17: datetime.date(2009,21,9,0,24), 19: datetime.datetime(2011,12,1,19,39,16),
I'm currently designing an app that calls for dynamically creating objects and then displaying
I am creating a system that will store objects in an SQLite Database. I
Why is it that for user defined types when creating an array of objects
I know how to gain access to management-objects. Lets say this one: var searcher
My models look like this: class Category(models.Model): name = models.CharField(_('name'), max_length=50) class Product(models.Model): name
I'm using Node.js and am creating some models for my different objects. This is
I am creating a flash object that does some heavy image lifting. What I
When creating a new entity object that has a foreign key value I need

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.