title: Ajax sometimes works, sometimes doesn't in Laravel
body: <p>I am trying to fetch data from my database using AJAX. My Laravel Controller returning string in JSON response. But my AJAX sometimes works, sometimes doesn't.I get "internal server error" when Ajax don't work i mean when the data is not loaded. But the problem doesn't happen in safari browser. Here is my AJAX code.</p>
  
  <pre><code> $(function(){
       var checking_html = '&lt;img src="img/loader.gif" /&gt;';
  
       $("#bond").change(function () {
           $('#load').html(checking_html);
           var x = $('#bond').val();
  
           $.ajax({
               type: 'POST',
               url: "{{ URL::route('bond.list') }}",
               data: {
                   '_token': $('input[name=_token]').val(),
                   'x': x
               },
               success: function(response) {
                   if(response[0]['bond_num'] == 400000){
                       response[0]['bond_num']='Premium';
                   }
                   html_output = '';
                   for(i=0; i&lt;response.length; i++){
                       html_output += '&lt;option value="'+response[i]['publish_date']+'"&gt;'+response[i]['publish_date']+' , '+response[0]['bond_num']+' Bond&lt;/option&gt;';
                       if(i==0){
                           html_output += '&lt;option value="all"&gt;ALL&lt;/option&gt;';
                       }
                   }
                   $('#choice').empty().append(html_output);
                   $('#load').html('');
               },
               error: function (jqXHR, textStatus, errorThrown){
                   alert('Error get data from ajax');
               }
           });
       });
   });
  </code></pre>