I have looked at a few post but cant seem to work out what I've done incorrect, i need to work with the JSON to inport into database but it saying my posted cities is not coming through?
Javascript
console.log(jsonData);
$.ajax({
url: "ajax.php",
type: "post",
data: jsonData,
datatype: 'json',
success: function(jsonData){
$('#result').html(jsonData);
},
error:function(){
alert('ajax failed');
}
});
}
Ajax.php
$obj = json_decode($_POST['cities']);
print_r($obj);
Error :
Notice: Undefined index: cities in ajax.php on line 3
Console Log for Json
{"currentCity":"Exeter","cities":[{"name":"Exeter","offers":[{"offer":"test","price":"11","notes":"100","city":"Exeter"}]}]}