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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T18:16:56+00:00 2026-06-16T18:16:56+00:00

I’m using backbone in my application and I’m attempting to update a json file

  • 0

I’m using backbone in my application and I’m attempting to update a json file using the backbone method .save method
here is the site http://dalydd.com/projects/backbone/backbone.html

here is my js this is working fine

 var ModalInfo = Backbone.Model.extend({
defaults: {
  person:'',
  occupation:'',
  home:'',
},
url:'sample.php',
});

 var developer = new ModalInfo();
developer.toJSON();
 developer.save({person:'madan', occupation:'developer', home:'middtown'}, {
wait:true,
success:function(model, response) {
console.log('Successfully saved!' + model + response);
},
 error: function(model, error) {
console.log(model.toJSON());
console.log('error.responseText' +model);
}
});

Here is the php in my sample.php I’m trying to get the contents of json.js decode it append it with my new data and then decode it and return it as the response

 <?php

 $json_data = json_decode(file_get_contents('json.js'), true);
 for ($i = 0, $len = count($json_data); $i < $len; ++$i) {
      //do the right logic
 }
 file_put_contents('json.js', json_encode($json_data));
 $final_data = file_get_contents('json.js', json_encode($json_data));
 echo $final_data;
 echo(var_dump($_POST));
 ?>

when i try to echo out the super global post I get array(0)

I’m hoping someone could help me out with my php and why I can’t extract any post data in sample.php when i use the .save method in backbone – when i echo out server request method it states post i just want to grab the post data and write it to the file and then return it am I going about this the wrong way – any help is appreciated – I have been racking my brain on this. My first step is just figuring out why i can’t get any post data even though firebug is telling me it’s posting when I load the page – you can check also

  • 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-16T18:16:57+00:00Added an answer on June 16, 2026 at 6:16 pm

    The answer to your question lies in that fact that unless you are posting form-encoded data, the $_POST superglobal does not get populated by PHP. You need to get at the raw posted input. You can do that like this:

    $json_data = json_decode(file_get_contents('php://input'));
    

    You can actually use any of the various PHP file input methods here (i.e fopen/fread, file (useless in this context), etc.) . However the above will probably be the easiest if you are not going to be dealing with large chunks of JSON input to the point where memory management becomes more of a concern.

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

Sidebar

Related Questions

I have a .ini file as follows: [playlist] numberofentries=2 File1=http://87.230.82.17:80 Title1=(#1 - 365/1400) Example
I have just tried to save a simple *.rtf file with some websites and
We are using XSLT to translate a RIXML file to XML. Our RIXML contains
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I'm not entirely sure how I managed to jack this up. http://pretty-senshi.com If you
I am using jsonparser to parse data and images obtained from json response. When
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
That's pretty much it. I'm using Nokogiri to scrape a web page what has
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I am using the SimpleRSS gem to parse a WordPress RSS feed. The only

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.