gpt4 book ai didi

javascript - Angular JS HTTP Post 不起作用

转载 作者:行者123 更新时间:2023-12-03 05:02:34 26 4
gpt4 key购买 nike

当我使用 XAMPP 使用本地计算机时,我的代码工作正常,但当我将网页上传到 InMotion 服务器时,它无法工作。

错误显示

[object Object]

我的代码:

$http.post("/aa/bb/public_html/php/checker.php",{"data1": val, "data2": para})
.then(function(response) {
if(para == "namedis"){
$scope.dsnamedis = response.data;
}else if(para == "namedise"){
$scope.dsnamedise = response.data;
}else if(para == "namein"){
$scope.dsnamein = response.data;
}else if(para == "namest"){
$scope.dsnamest = response.data;
}else if(para == "namemd"){
$scope.dsnamemd = response.data;
}else if(para == "namels"){
$scope.dsnamels = response.data;
}else if(para == "email"){
$scope.dsemail = response.data;
}else if(para == "pass"){
$scope.dspass = response.data;
}else if(para == "passc"){
$scope.dspassc = response.data;
}else if(para == "idno"){
$scope.dsidno = response.data;
}else if(para == "phoneno"){
$scope.dsphoneno = response.data;
}else{


}


}, function(error,status) {

$scope.fstatus = { message: error, status: status};
console.log(status);
});

我的 PHP 代码:

<?php
$gc = file_get_contents("php://input");
$datas = json_decode($gc, true);
$cc = $datas['data1'];
$dd = $datas['data2'];
if($dd == "namedis"){
echo "<span class='text-danger'> <i class='fa fa-times-circle-o' aria-hidden='true'></i>aaaa.</span>";
}elseif($dd == "namedise"){

and so on

如何解决这个问题。

当我删除 .htacess 文件时,它工作正常。如何使用 .htacess 文件进行操作。

RewriteBase /

DirectorySlash Off
DirectoryIndex disabled

RewriteEngine on

# prevent direct access to PHP files
RewriteCond %{ENV:REDIRECT_STATUS} ^$
RewriteRule \.php$ - [R=404,L]

# rewrite requests for a directory to index.php
RewriteCond %{REQUEST_FILENAME}/index.php -f
RewriteRule ^.*$ /$0/index.php [L]

Options -Indexes

ErrorDocument 403 /errors/403error.php

ErrorDocument 404 /errors/404error.php

最佳答案

$http.post("/../.../public_html/php/checker.php"

这是一种绝对错误的提出请求的方式。

阅读the basics欢迎来到网络开发的美丽世界!

关于javascript - Angular JS HTTP Post 不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42160300/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com