Using the method found here, I am collecting form values and posting them using the following code:
$.ajax({
type: "POST",
url: "http://"+document.domain+"/SimplaAdmin/includes/rpc.php",
data: { data:postdata, method: 'addSite'},
dataType: "json",
.......
Posted data is:
data:{
"textfield": ["",""],
"dropdown": ["option1","option1"],
"siteTitle":"this is the site title",
"siteKey":"",
"siteurl":"",
"address1":"",
"address2":"",
"address3":"",
"landline":"",
"method":"addSite",
"small-input":"",
"medium-input":"",
"large-input":""
}
Then I try to get the value siteTitle
using:
$data = $_POST['data'];
$obj=json_decode($data) ;
$title = $obj->{'siteTitle'};
But it does not work, where is the flaw in my thinking?