Answer the question
In order to leave comments, you need to log in
Why doesn't Ajax work in Laravel?
There is a js file:
//
// Точка входа.
//
$(document).ready(function(){
$.ajaxSetup({
headers: {
'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
}
});
// При нажатии на кнопку id=send
$('.remember').click(function(){
var id_advert = $(this).val();
$(this).html("<button type='checkbox' disabled='disabled' name='remember' class='remember'> Запомнили </button>");
$.get('true_advert',{remember:id_advert});
});
/*$('#send').click(function(){
var params = $('#register').serialize();
$.post('auth/register',params);
});*/
$('.comment').click(function(){
var id_comment = $(this).val();
console.log(id_comment);
//$(this).html("<textarea rows=10 cols=70 name='add_comment' class='add_comment' maxlengh='256' autofocus> </textarea><br><button type='submit' name='add' class='add'> Добавить сообщение</button>");
$.get('edit_advert',{comment:id_comment},function(data,textStatus,jqXHR)
{
console.log(data);
console.log(textStatus);
console.log(jqXHR);
});
});
});
$('.comment').click(function(){
var id_comment = $(this).val();
console.log(id_comment);
//$(this).html("<textarea rows=10 cols=70 name='add_comment' class='add_comment' maxlengh='256' autofocus> </textarea><br><button type='submit' name='add' class='add'> Добавить сообщение</button>");
$.get('edit_advert',{comment:id_comment},function(data,textStatus,jqXHR)
{
console.log(data);
console.log(textStatus);
console.log(jqXHR);
});
});
public function id_advert(Request $request)
{
$data['id_advert'] = $request->input('comment');
return view('aaa',$data);
//Adverts::add_comment($comment,$id_client,$id_advert);
}
Route::get('edit_advert','[email protected]_advert');
<button type="submit" value="{{$advert->id_realty}}" name="comment" class="comment"> Добавить комментарий</button>
<meta name="csrf-token" value="{{ csrf_token() }}">
<input type="hidden" id="token" value="{{ csrf_token() }}">
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question