R
R
RodgerFox2015-11-14 20:09:11
Angular
RodgerFox, 2015-11-14 20:09:11

How to solve a wretched error, with getting an object?

Hello everyone, this is some kind of tin.
With $resource:

'create': {
            method: 'POST'
        }

there is a request to create a record in the database, from the form
//...
//запрос к модуле, выполнения запроса, вызов return $this->db->getLastId(); (возвращает уникальный идентификатор, только что созданный)
// отправляем назад
$this->response->setOutput(json_encode($data));

in the response we get the id of the created record (object), after we find out what is in it: {"0":"3","1":"0"}. How to make 30 out of this?
manipulation:
SettingProject.create({}, data).$promise
        .then(function(data) {
            console.log('получаем: '+data); // получаем: [object Object]
            console.log(angular.fromJson(data)); // e {0: "3", 1: "0", $promise: d, $resolved: true}
            console.log(JSON.stringify(data)); // {"0":"3","1":"0"}
        }, function(error) {
            console.log(error);
});

I'm sure it's some kind of minor flaw, but I'm a beginner and every movement goes through terrible thorns

Answer the question

In order to leave comments, you need to log in

1 answer(s)
R
RodgerFox, 2015-11-15
@RodgerFox

Seriously? How to get the integer 30 from the object {"0":"3","1":"0"}?
$.parseJSON gives an error:

SyntaxError: Unexpected token o at Object.parse (native) object $.JsonPars

How to influence at the level of php, also to no avail ... =(

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question