Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/delphi/9.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
Angularjs和api之间的内部服务器错误500_Angularjs_Api - Fatal编程技术网

Angularjs和api之间的内部服务器错误500

Angularjs和api之间的内部服务器错误500,angularjs,api,Angularjs,Api,我试图保存angularjs发送到api的数据,但出现错误500内部服务器错误。控制器是一个数组,用于保存来自html页面的作用域。 有什么帮助吗 控制器 $scope.save = function () { $scope.setup.push({ "Spec_Code": $scope.spec, "Medical_CTG": $scope.deg, "Doctor_Code": $scope.st, "Main_Serv": $scope.stypecode, "S

我试图保存angularjs发送到api的数据,但出现错误500内部服务器错误。控制器是一个数组,用于保存来自html页面的作用域。 有什么帮助吗

控制器

$scope.save = function ()
{
    $scope.setup.push({
        "Spec_Code": $scope.spec, "Medical_CTG": $scope.deg, "Doctor_Code": $scope.st, "Main_Serv": $scope.stypecode, "Serv_Group": $scope.sgroupcode, "Sub_Serv": $scope.sub,
        "Pat_Type": $scope.patype, "Calc_Type": $scope.calcs, "Calc_From": $scope.rfrom, "Calc_Val": $scope.calcvalue, "STAFF_TYPE": $scope.stafftype,
        "pricelist": $scope.selectedpricelist
    })


    var promisePost = Doctorssetup.save($scope.setup);
    promisePost.then(function (pl) {
    }, function (err) {
        console.log("Err" + err);
    });
    console.log($scope.setup);
}


    var promisePost = Doctorssetup.save($scope.setup);
    promisePost.then(function (pl) {
    }, function (err) {
        console.log("Err" + err);
    });
    console.log($scope.setup);
}
原料药


非常感谢

您在控制器上的函数需要一个对象,但您正在尝试发布一个数组。修改如下:

$scope.setup = {
        "Spec_Code": $scope.spec, "Medical_CTG": $scope.deg, "Doctor_Code": $scope.st, "Main_Serv": $scope.stypecode, "Serv_Group": $scope.sgroupcode, "Sub_Serv": $scope.sub,
        "Pat_Type": $scope.patype, "Calc_Type": $scope.calcs, "Calc_From": $scope.rfrom, "Calc_Val": $scope.calcvalue, "STAFF_TYPE": $scope.stafftype,
        "pricelist": $scope.selectedpricelist
    });

在使用JSON.stringify$scope.setup发布之前,也要转换为字符串

请,请仔细阅读。您的500可能带有错误消息和堆栈跟踪。也请阅读。打开浏览器开发工具“网络”选项卡-什么是HTTP请求方法?身体那么响应的响应体是什么
$scope.setup = {
        "Spec_Code": $scope.spec, "Medical_CTG": $scope.deg, "Doctor_Code": $scope.st, "Main_Serv": $scope.stypecode, "Serv_Group": $scope.sgroupcode, "Sub_Serv": $scope.sub,
        "Pat_Type": $scope.patype, "Calc_Type": $scope.calcs, "Calc_From": $scope.rfrom, "Calc_Val": $scope.calcvalue, "STAFF_TYPE": $scope.stafftype,
        "pricelist": $scope.selectedpricelist
    });