It is necessary when clicking on the link, for example on:

<div class="col m3 like"><a name="Like"><i class="fa fa-thumbs-o-up " aria-hidden="true"></i></a></div> 

So that the information from the next diva goes to the base:

 <div class="border "><p class="likeNum">{{$post->likes}}</p></div> </div> 

without refreshing the page. I know what needs to be done through ajax, but it seems that I haven’t been asleep for too long, so that I can figure out how to do it, can you tell me?

 <div class="col m4 s12"> <div class="car "> <div class="foto"> <div class="infoTab center"><a href="{{url('/postinfo/')}}/{{$post->id}}"><i class="fa fa-plus-square-o fa-5x"></i></a></div> <img src="{{ $post->images[0]->img_path }}" alt="Car Photos"> </div> <div class="postInfo"> <div class="nickName left"><p>{{$post->user->username}}</p></div> <div class="date right"><p>{{$post->date}}</p></div> </div> <div class="carNumber"> <div class="flag"> <img src="img/Azerbaijan.png"> <p>AZ</p> </div> <p>{{$post->numbers[0]->nmb_title}}</p> </div> <div class="row"> <div class="col m12 "> <div class="row"> <div class="col m8 DL"> <div class="row"> <div class="col m5"> <div class="row"> <div class="col m3 like"> <a name="Like"><i class="fa fa-thumbs-o-up " aria-hidden="true"></i></a> </div> <div class="col m6"> <div class="border "><p class="likeNum">{{$post->likes}}</p></div> </div> </div> </div> <div class="col m5 "> <div class="row"> <div class="col m3 disLike"><a name="DisLike"><i class="fa fa-thumbs-o-down " aria-hidden="true"></i></a></div> <div class="col m6"> <div class="border"><p class="dislikeNum">{{$post->dislikes}}</p></div> </div> </div> </div> </div> </div> <div class="col m4 right share"> <a href="https://www.facebook.com/sharer.php?u=http://localhost:8000/postinfo/{{$post->id}}/FBshareArticle"><i class="fa fa-facebook-square " aria-hidden="true"></i></a> <a href=""><i class="fa fa-twitter-square " aria-hidden="true"></i></a> </div> </div> </div> </div> 

  • What have you tried to do, what exactly did you fail? Maybe you should sleep and try to solve the problem yourself, and not ask others to work? - Alexey Ukolov
  • unfortunately with time too tight =) if there would be an opportunity not to strain people - Rovshan Agaev
  • In this case, you are on any freelance exchange. There you will solve the problem and will not strain anyone. - Alexey Ukolov
  • thanks for the idea - Rovshan Agaev

1 answer 1

If you have jQuery connected, you can do something like this:

 <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <script type="text/javascript"> $("a[name=Like]").on('click', function(e) { e.preventDefault() $.ajax({ type: 'GET', url: $(this).attr('href'), data: { 'my_var': $("p.likeNum").text() }, success: function(data) { alert("Request Successful") }, error: function(xhr, str) { alert('Возникла ошибка: ' + xhr.responseCode); } }); }); </script> 

Well, then in the controller to process this variable:

 if (Request::ajax()) { $myVar= Request::only('my_var'); // Делаем то что нужно с переменной }