我有以下请求ajax:
$("#btnSave").click(function()
{
var Url = 'http://localhost/Projetos-Laravel/Sibcomweb/public/panel/client/save';
var Dados = $('#FormClient').serialize();
$.ajax({
type:'POST',
url:Url,
dataType: 'JSON',
data: Dados,
success:function(data){
if($.isEmptyObject(data.error)){
alert(data.msg);
}else{
alert('have errors');
}
},
error:function(e){
alert('Error !');
log.console(e);
},
});
});
错误log.console(e)
POST http://localhost/Projetos-Laravel/Sibcomweb/public/panel/client/save 500 (Internal Server Error)
send @ jquery.js:9566
ajax @ jquery.js:9173
(anonymous) @ create:431
dispatch @ jquery.js:5206
elemData.handle @ jquery.js:5014
create:446 Uncaught ReferenceError: log is not defined
at Object.error (create:446)
at fire (jquery.js:3317)
at Object.fireWith [as rejectWith] (jquery.js:3447)
at done (jquery.js:9274)
at XMLHttpRequest.<anonymous> (jquery.js:9514)
请求ajax转到控制器但在验证方法中有一些错误...
我认为问题出在验证方法中,我做错了什么?
public function store(Request $request)
{
$dataForm = $request->all();
$rules =[
'name'=>'required|min:3|max:100',
'number'=>'required|numeric',
];
$valida = validator($dataForm, rules);
if($valida->fails())
{
return $valida;
}
else
return 'Ok';
}
我怎么做返回类型为json的var valida?
日志不是一个功能。将qazxsw poi改为qazxsw poi
要查看响应错误:
无法更改您的回调函数:
log.console
有两个问题。首先它是:log.console(e),但是是console.log(e)。第二个问题是在控制器中,返回方法不正确。
这样它是正确的:
console.log