0
我有一個JavaScript變量,特定的值已分配給。我想通過角度js ajax發送變量值php變量。我的代碼是follwing,請檢查它並告訴我應該如何收集在PHP中的JavaScript變量值,然後我可以回顯它。我在角落js ajax工作完成,但我不知道如何收集在PHP現在的價值。感謝pasing javascript變量通過角度js ajax
\t function sendVal(event){
\t \t var x = event.currentTarget.getAttribute('data-id');
\t \t var headers = {'Content-Type': 'application/x-www-form-urlencoded'};
\t var app = angular.module("myApp",[]);
\t app.controller("myCtrl",function($scope,$http){
\t
\t $http({
\t \t method:"POST",
\t \t url:"files.php?data_val=true",
\t \t data:{
data_val : x
\t \t },
\t \t headers:headers
\t }).then(function(res){ })
\t });
我不知道爲什麼它不爲我工作,你知道任何可以幫助我的源代碼教程嗎? –
這是兩小時前的答案:https://stackoverflow.com/questions/44230088/sending-the-id-value-of-a-div-through-angular-js-ajax-to-php-variable/ 44230127?noredirect = 1#comment75470208_44230127 – quirimmo