Thursday, March 30, 2017

Ajax success function not working in laravel

My blade view-

@foreach ($songs as $song)
     <a href="" download="" >
        <button type="button" class="download" style="margin-bottom: 15px;">
           <i class="glyphicon glyphicon-download">Download</i>
        </button>
     </a>
 @endforeach

My ajax success function does not work. it doesn't show alert. Therefore I cannot update my database. Here is my ajax:

$(function() {
  $('.download').click(function(){
 $.ajax({
   url: "/update_download_count",
   type:"POST",
   data: {
     song_id:$(this).attr('data-id')
   },
success: function(data)
                        {
                            alert("ok");        
                        }
  });
});
    }); 

So, Whats wrong with my ajax call? I want to click on link and pass the the id to my controller.



via Himu

Advertisement