-1

这里我通过 $http.post 将数据发送到 data/user.php

app.factory('loginService',function($http){
    return{
        login:function(data,scope){
            var $promise=$http.post('data/user.php',data); //send data to user.php
            $promise.then(function(msg){
                if(msg.data=='succes') scope.msgtxt='Correct information';
                else                   scope.msgtxt='incorrect information';
            });
        }
    }

});

数据/user.php 代码

<?php 
    $user=json_decode(file_get_contents('php://input'));  //get user from 
    if($user->mail=='elgaliamine@gmail.com' && $user->pass=='1234') 
        print 'succes';
    else 
        print 'error';
?>

http://localhost:8000/app/data/user.php 404 (Not Found) 并且浏览器在我尝试时不断显示 mePOSThttp://localhost:8000/app/data然后它显示存在user.php

为什么它给出404错误?请帮帮我...

4

2 回答 2

1

我得到了解决方案...实际上我正在运行整个项目npm start

http://localhost:8000/app/index.html?#/login

所以我收到了 404 错误

现在我已经在apache下打开它了

http://localhost/login/app/index.html?#/login

它现在工作..

于 2014-07-18T11:18:01.257 回答
0

即使我在 npm start 下运行整个项目,我也收到了相同的错误消息。我做错的事情是“ action=" " method="post" "

  • form class="business_customer" action="" method="post" id="contact_form" ng-submit="addDetails()"

我从我的 html 中删除了 action=" " method="post" ,现在它可以正常工作了

  • 表单类="business_customer" id="contact_form" ng-submit="addDetails()"
于 2016-04-27T22:04:25.413 回答