Вот как выглядит моя функция angularJS:
Код: Выделить всё
app.controller('myCtrl', function($scope, $http) {
$scope.executefunc = function(name, price) {
var data = {
action: 'setcart',
bname: name,
bprice: price
};
$http.post('cart.php', data)
.then(function(response) {
alert('Response: ' + JSON.stringify(response.data));
}, function(error) {
console.error('Error:', error);
alert("Failed to add to cart. Please try again.");
});
};
});
вот какой мой PHP-файл выглядит так:
Код: Выделить всё
Подробнее здесь: [url]https://stackoverflow.com/questions/78735719/trying-to-access-the-data-ive-sent-through-post-method-to-another-file-in-php[/url]