Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/249.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 我无法通过POST方法将请求从angularjs发送到php_Javascript_Php_Jquery_Angularjs - Fatal编程技术网

Javascript 我无法通过POST方法将请求从angularjs发送到php

Javascript 我无法通过POST方法将请求从angularjs发送到php,javascript,php,jquery,angularjs,Javascript,Php,Jquery,Angularjs,我正在尝试构建小型应用程序。它包含文本区和一个按钮面板,当我把第一个字母放在这个文本区时,它会显示在下面。我不得不使用isButtonVisible方法。它很好用。当我点击SendRequestwithdatafromTextArea到data.php脚本,通过方法POST它是我的任务点时,问题就开始了。它必须是send方法。当请求完成时,脚本应该显示JavaScript警报和保存的数据 我的angularjs脚本ng-controller.js如下所示: angular.module("Tex

我正在尝试构建小型应用程序。它包含文本区和一个按钮面板,当我把第一个字母放在这个文本区时,它会显示在下面。我不得不使用isButtonVisible方法。它很好用。当我点击SendRequestwithdatafromTextArea到data.php脚本,通过方法POST它是我的任务点时,问题就开始了。它必须是send方法。当请求完成时,脚本应该显示JavaScript警报和保存的数据

我的angularjs脚本ng-controller.js如下所示:

angular.module("Textarea", []).controller("TextAreaCtrl", TextAreaCtrl);

function TextAreaCtrl($scope, $http)
{
    'use strict';

    $scope.success = false;
    $scope.httpError = false;

    this.isButtonVisible = function()
    {
        return $scope.text;
    };

    this.send = function ()
    {
        var data = $scope.text;

        if(!data)
            return false;

        $http.post('data.php', data)
        .success(function (data)
        {
            $scope.success = true;
        })
        .error(function (data)
        {
            $scope.httpError = true;
        });
    };
};

必须在控制器内定义“$http”的用法,然后才能在函数中使用它

angular.module("Textarea", []).controller("TextAreaCtrl", ['$scope', '$http', function($scope, $http) {
  $scope.orderList = function() {
    $http.post('http://example.com').
      success(function(data) {
        $scope.data = data;
      }).
      error(function(data, status) {
        console.log(data);
        console.log(status);
      });
    };
}];

data.php位置。。。??我说的是你的项目hierarchydata.php在同一个文件夹中。php最终会起作用。它显示来自textarea的数据,并将其保存在data.txtAny控制台中出错…?2个错误:加载资源失败:服务器响应状态为404未找到/Angular%20-%20Textarea_文件/Angular.min.js.map:1 GET 404 Not Found修复这些错误然后。。。您可以从Angular的网站下载地图文件。我更改了这些文件的第一行,但它仍然不起作用。data.php应该如何接收这些数据?