我正在开发angularJS应用程序,我需要使用$ resources并将$ _POSY值传递给php文件,然后我将值设置为$ _SESSION并结束php脚本。
这是我写的代码:
var setData = function(place) {
// Angular $http() and then() both return promises themselves
return $resource('./PHP/session/placeSession.php').
save({ lastPlace: json }).
$promise.then(function(res) {
console.log(res + " " + json);
}).catch(function (err) {
console.log(err);
});
};
这就是placeSession.php
<?php
session_start();
$_SESSION['lastPlace'] = $_POST['lastPlace'];
?>
是不是?如果我在控制台中显示它,则lastPlace中的值为:[object Object]。