0
エラーが表示されない問題が発生しました。ページにエラーが表示されない
$rules = ['firstname' => 'required|max:20',
'lastname' => 'required|max:10',
'phone' => 'required|max:15',
'email' => 'required|email',
'address' => 'required',
'country' => 'required',
'city' => 'required',
'role' => 'required',
'status' => 'required'];
$validator = Validator::make(Input::all(),$rules);
if($validator->fails())
{
$error='';
$mess = $validator->getMessageBag()->toArray();
foreach($mess as $row => $val)
{
foreach($val as $key)
{
$error .=$key." <br />";
}
}
//return json_encode(array('message'=>$error));
return Response::json(array('message'=>$error));
}
エラーがさえコンソールに表示されていません。
は、ここに私のコード
$.ajax({
url: '{{ url("userposteditajax") }}',
dataType: 'json',
type: 'post',
data: {firstname:firstname,lastname:lastname,phone:phone,email:email,address:address,country:country,city:city,password:password,role:role,status:status,id:id},
success: function(data, textStatus, jQxhr){
if(data.message == 'Success')
{
$('#ajax_submit').prop('disabled', false);
location.reload();
$.magnificPopup.close();
}
else {
var errors = data.message;
$('#ajax_submit').prop('disabled', false);
$.each(errors, function(key, value) {
// console.log(errors);
$('#ajax_error').fadeIn('slow',function(){
$('#ajax_error_mess').html(value);
});
});
}
},
error: function(jqXhr, textStatus, errorThrown){
$('#ajax_submit').prop('disabled', false);
var errors = jqXhr.responseJSON;
$.each(errors, function(key, value) {
$('#ajax_error').fadeIn('slow',function(){
$('#ajax_error_mess').html(value);
});
});
}
});
return false;
});
私のコントローラのコードです。
私が手に応じた出力は、私はあなたのコードのいくつかの変更をした
{"message":"The firstname field is required. <br \/>The lastname field is required. <br \/>The email field is required. <br \/>The address field is required. <br \/>"}
我々が手にマジックボールを持っていません。コンソールにエラーはありますか? htmlの値は何ですか?それ以外の条件で休憩を取ったのですか? –
私は何が得られたかのエラー、何もコンソールに表示されていません。 before $ .each(errors、function(key、value){........................}私はコンソールにデータを表示するとエラーが発生しますコンソールに表示されます –