you must parse JSON string to become object
var dataObject = jQuery.parseJSON(data);
so you can call it like:
success: function (data) {
var dataObject = jQuery.parseJSON(data);
if (dataObject.success == 1) {
var insertedGoalId = dataObject.inserted.goal_id;
...
...
}
}