Вот моя функция AngularJSИзвлечь данные, отправленные из программы Angular to php?
'use strict';
app
.factory('userProvider', function ($rootScope , $http) {
function logIn(user) {
var url='http://127.0.0.1:100/suitecrm/service/rest.php';
/*$http.post(url,user)
.success(function (response) {
console.log(response);
alert(user['username']); //data is displayed normally here
alert(user['password']); //data is displayed normally here
});
*/
$http({
method: 'POST',
url: 'http://127.0.0.1:100/suitecrm/service/rest.php',
//data: 'username: user['username'] , password: user['password'] }
data: { username: user['username'] , password: user['password']}
}).then(function successCallback(response) {
console.log(response);
}, function errorCallback(response) {
// called asynchronously if an error occurs
// or server returns response with an error status.
});
}
return {
logIn: logIn
}
});
Я хочу восстановить два переменных пользователя и пароль в моем файле rest.php. Вот код, где я получить имя пользователя и пароль
$username =$_POST['username'];
$password =$_POST['password'];
Но когда я открываю консоль выводится сообщение об ошибке: Имя пользователя & пароль не определен в rest.php так, как я могу получить данные в моем файле rest.php правильно.
Это ошибка в консоли: Примечание: Неопределенный индекс: имя пользователя в C: \ Users \ hp1 \ Desktop \ Stage \ SugarCrm Thinline \ suitecrm \ service \ rest.php на линии
Примечание: Undefined индекс: пароль в C: \ Users \ hp1 \ Desktop \ Stage \ SugarCRM Thinline \ suitecrm \ сервис \ rest.php на линии
–