这里我通过$ 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';
});
}
}
});
data / user.php code
<?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';
?>
并且浏览器不断显示mePOST http://localhost:8000/app/data/user.php 404 (Not Found)
在尝试http://localhost:8000/app/data
时,它会显示存在user.php
为什么它会给出404错误?请帮帮我...
答案 0 :(得分:1)
我得到了解决方案......
实际上我在npm start
http://localhost:8000/app/index.html?#/login
所以我得到了404错误
现在我在apache下打开它
http://localhost/login/app/index.html?#/login
现在正在工作..
答案 1 :(得分:0)
即使我在npm start下运行整个项目,我也收到了相同的错误消息。 我做错的事是#34;行动=&#34; &#34;方法=&#34;后&#34; &#34;
我删除了操作=&#34; &#34;方法=&#34;后&#34;从我的HTML,现在它完美地工作