Advertisement
Guest User

Untitled

a guest
Jun 18th, 2019
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.46 KB | None | 0 0
  1. $.ajaxSetup({
  2. headers: {
  3. 'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
  4. }
  5. });
  6.  
  7. $('#search_user_form_profile').on('keyup',function(){
  8. $value=$(this).val();
  9. $.ajax({
  10. method: 'POST',
  11. url: '{{route('user.profile.search')}}',
  12. data: {
  13. 'data' : $value
  14. },
  15. success: function(response){
  16. console.log(response);
  17. var html = '';
  18. for(let i = 0; i < response.message.length; i++)
  19. {
  20. let tempHtml = "<span class="border-bottom border-dark"> <a href="" style="width:25vw;font-size: 1em;">" + response.message[i].name + "</a></span><br>";
  21. html = html + tempHtml;
  22. }
  23. console.log(html);
  24. $( "div.demo-container" )
  25. .html(html);
  26. },
  27. error: function(jqXHR, textStatus, errorThrown) {
  28. console.log(jqXHR, textStatus, errorThrown);
  29. }
  30. });
  31. })
  32.  
  33. if(request()->ajax()){
  34. $input = Input::get('data');
  35. $user = User::where('name', 'LIKE', '%' . $input . '%')
  36. ->where('id', '!=', auth()->user()->id)
  37. ->get();
  38. return response()->json(['status' => 'success', 'message' => $user]);
  39. } else {
  40. return response()->json(['status' => 'fail', 'message' => 'an error occurred']);
  41. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement