Javascript 使用laravel验证后ajax上的成功函数
我通过ajax使用laravel对表单进行了验证。发送数据和验证工作正常,但当收到js代码中的答案时,success函数从未执行;如果验证中有错误,则执行错误函数,如果验证中没有错误,则也输入错误。 出错时,它返回状态laravel:422,如果没有错误,则返回laravel状态:200 感谢您可能提供的帮助:) js: 拉雷维尔: 用户控制器:Javascript 使用laravel验证后ajax上的成功函数,javascript,jquery,ajax,laravel,Javascript,Jquery,Ajax,Laravel,我通过ajax使用laravel对表单进行了验证。发送数据和验证工作正常,但当收到js代码中的答案时,success函数从未执行;如果验证中有错误,则执行错误函数,如果验证中没有错误,则也输入错误。 出错时,它返回状态laravel:422,如果没有错误,则返回laravel状态:200 感谢您可能提供的帮助:) js: 拉雷维尔: 用户控制器: <?php namespace App\Http\Controllers; use Illuminate\Http\Request; use
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use Validator;
use App\Http\Controllers\Controller;
use App\Http\Requests;
use App\Http\Requests\UserRequest;
class UserController extends Controller
{
public function index()
{
return view('home');
}
public function NewUser(UserRequest $request)
{
// laravel will validate request itself automatically and
// will go on if validate pass or will return back with
// status code 422, input and errors otherwise
CreateNewUser($request);
}
Protected function CreateNewUser(Request $request){
}
}
这是因为您的代码中有错误
CreateNewUser($request);
需要
$this->CreateNewUser($request);
及
需要:
protected function CreateNewUser(Request $request){
这是因为代码中有错误
CreateNewUser($request);
需要
$this->CreateNewUser($request);
及
需要:
protected function CreateNewUser(Request $request){
您好@Ohgodwhy,谢谢您纠正了这个错误,但是函数Create new user在验证后运行。我纠正并做了测试,但仍然输入了错误的ajax函数。您好@Ohgodwhy,感谢您纠正了错误,但是函数创建新用户在验证后运行。我更正并进行了测试,但仍然输入了错误的ajax函数。