Php Ajax调用中的TypeError
我在Laravel 5中的Ajax调用中遇到以下错误: TypeError:对未实现接口HTMLInputElement的对象调用了“Stepp” d=[],e=函数(a,b){b=n.isFunction(b)?b():null==b?”:b 表格如下:Php Ajax调用中的TypeError,php,jquery,ajax,routing,laravel-5,Php,Jquery,Ajax,Routing,Laravel 5,我在Laravel 5中的Ajax调用中遇到以下错误: TypeError:对未实现接口HTMLInputElement的对象调用了“Stepp” d=[],e=函数(a,b){b=n.isFunction(b)?b():null==b?”:b 表格如下: <form id="comment_form"> <input type="textarea" class="form-control_comment" id="comment" placeholder="Type
<form id="comment_form">
<input type="textarea" class="form-control_comment" id="comment" placeholder="Type your comment here...">
<input type="hidden" name="uid" id="uid" value="{{$user->id}}">
<input type="hidden" name="pid" id="pid" value="{{$post->id}}">
<input type="hidden" id="token" value="{{$csrf_token()}}">
<button type="button" class="btn btn-sm btn-success" id= "comment_button">Submit</button>
</form>
以及后置控制器中的操作部分:
public function postComment_action()
{
if(Auth::check())
{
if(Request::ajax())
{
$inputs= Input::all();
}
$new_comment= $inputs['newComment'];
$uid= $inputs['uid'];
$pid= $inputs['pid'];
$com= new Comment;
$com->content= $new_comment;
$com->userId= $uid;
$com->postId= $pid;
$com->save();
$data= array();
$all_comments= Comment::where('postId', $pid)->first();
$u= User::where('id', $uid);
foreach($all_comments as $coms)
{
$data= $coms->content;
}
$data= json_encode($data);
echo $data;
}
else
{
return Redirect::route('signin_user')->withErrors("You must sign in to perform this action");
}
}
任何帮助都将不胜感激:)
Route::post('post/comment_action', array('as'=>'post/comment_action', 'uses'=>'PostController@postComment_action'));
public function postComment_action()
{
if(Auth::check())
{
if(Request::ajax())
{
$inputs= Input::all();
}
$new_comment= $inputs['newComment'];
$uid= $inputs['uid'];
$pid= $inputs['pid'];
$com= new Comment;
$com->content= $new_comment;
$com->userId= $uid;
$com->postId= $pid;
$com->save();
$data= array();
$all_comments= Comment::where('postId', $pid)->first();
$u= User::where('id', $uid);
foreach($all_comments as $coms)
{
$data= $coms->content;
}
$data= json_encode($data);
echo $data;
}
else
{
return Redirect::route('signin_user')->withErrors("You must sign in to perform this action");
}
}