I am implementing Backbone.js, and I am just trying to understand how the sync function works. To keep it very simple, here is the model.
var Item = Backbone.Model.extend({
defaults: {
name: "Goo"
},
url: "commlink.php"
});
and then
Backbone.sync("create", item);
This is my commlink.php
$item=json_decode($_POST);
$name=$item->name;
$results=$mdb2->query("INSERT INTO list VALUES (NULL, '$name')");
I see a new row show up in my DB, however, the field "name" is blank. I tried both item.save() and the above method...both ended up with the same blank cell but a new entry.
This is the error in chrome in network/content:
<b>Warning</b>: json_decode() expects parameter 1 to be string, array given in ...XXX...
This is in the request payload:
{"name":"Goo"}