2017-02-10 21 views
0

XAMPPを使用してローカルコンピュータを使用しているとき、私のコードは正常に動作していますが、自分のWebページを自分のInMotion Serverにアップロードすると動作しません。Angular JS HTTPポストが動作しない

$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 
+1

ほとんどのホストの 'public_html'ディレクトリの上にはアクセスできません、それはウェブのルートディレクトリです。 ker.php "' – charlietfl

+0

ええ、私はすでにこのように使っていますが、動作していません。 – user43153

+0

あなたの編集では、 'public_html'と' public_html'ディレクトリの上のディレクトリにアクセスしようとしています。あなたはそれをすることはできません。あなたは 'public_html'の中にあるものだけにアクセスすることができます – charlietfl

答えて

1

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

これは、要求を行うために絶対に間違った方法である。

the basicsを読んでください。ウェブ開発の美しい世界へようこそ!

+0

$ httpを教えていただきありがとうございます。 post( "/../.../public_html/php/checker.php"これは同じものではありません。この$ http.post( "/ aaa/bb/public_html/php/checker.php" – user43153

+0

$ http.post( "http://www.aa.lk/php/checker.php"、{"data1":val、 "data2":para})を試してみました。これもウォーキングしていません。 – user43153

+0

$ http.post( "http://example.com/checker.php" のようにサイトのルートディレクトリはどこですか? – TheSameSon

関連する問題