を推奨されていません、私はLaravel 5.2に設定したルートに$ http.post AJAXデータ、すべてが完璧に動作しますが、サーバーが返すこのエラーを送信しようとしています:
Deprecated: Automatically populating $HTTP_RAW_POST_DATA is deprecated and will be removed in a future version. To avoid this warning set 'always_populate_raw_post_data' to '-1' in php.ini and use the php://input stream instead. in Unknown on line 0
Warning: Cannot modify header information - headers already sent in Unknown on line 0
これは私のコードです。 PHP:
public function save(Request $request){
$input = $request->all();
try {
$direccion = urlencode($input['Calle']." ".$input['Numero'].", ".$input['Ciudad']);
$geocode = "https://maps.googleapis.com/maps/api/geocode/json?address=$direccion&key=APIKEY";
$datosGoogle = json_decode($this->curl($geocode), true);
$latitud = $datosGoogle['results'][0]['geometry']['location']['lat'];
$longitud = $datosGoogle['results'][0]['geometry']['location']['lng'];
if(is_double($latitud) && is_double($latitud)){
$input['Latitud'] = $latitud;
$input['Longitud'] = $longitud;
$new = MyModel::create($input);
$data = ["status"=>"ok", "message"=>"Agregado correctamente"];
}else{
$data = ["status"=>"fail", "message"=>"Dirección desconocida, compruebe que los datos son correctos para que podamos agregarla al sistema."];
}
} catch (Exception $e) {
$data = ["status"=>"error", "message"=>$e->getMessage()];
}
return response()->JSON($data);
}
JS:
$scope.registrar = function(form, datos) {
$scope.submitted = true;
if(form.$valid) {
var toSendData = JSON.stringify({
Nombre: datos.nombre,
Calle: datos.calle,
Numero: datos.numero,
Piso: datos.piso,
Puerta: datos.puerta,
CP: datos.cp,
Ciudad: datos.ciudad,
Email: datos.email,
Necesidades: datos.necesidades,
Telefono: datos.telefono
});
console.log(toSendData);
$http.post($rootScope.recibirNuevoUrl, toSendData).then(function(response){
$scope.hideLoading();
if(response.data.status == "ok"){
$state.go('registro');
}else{
$scope.$parent.showAlert("Error al introducir los datos", response.data.message);
}
})
}else{
$scope.$parent.showAlert('Validacion de datos', 'El formulario contiene errores. Por favor revise los campos marcados para comprobar los errores.');
}
};
私はそれを解決することができますか?
私はこの解決策のために何千もの投稿とウェブをレビューしました。ちょっと説明してもらえますか(同じ問題でここに来た新しい人たちを考えて)?百万のおかげで! –