2

I have a problem with a Laravel AJAX response. The request is GET not POST This is the API URL: http://example.com/app/public/index.php/api/userdata and I never receive an AJAX response. In my Chrome browser I get the following error net::ERR_CONNECTION_RESET, but when I go to the API URL directly from Chrome I get the JSON response and it's correct. This only happens for AJAX requests and I also have "Provisional headers are shown" in my AJAX request. I'm using Ember for AJAX requests, but I also tried using jQuery $.getJSON and I got the same result.

I read some discussion about "Laravel Connection Reset" and I tried to disable opcache but this is still happening.
This is my enviroment

  • PHP Version 7.0
  • Laravel 5.1.39(LTS)
  • Ubuntu 14.04.4 LTS
  • jQuery 1.11.3
  • Ember 2.0.2

This is my controller code :

 public function index()
  {
      $inputs = Input::all();
      $userData = UserData::inMyCompany();
      if(isset($inputs['filters']))
      {
          foreach($inputs['filters'] as $field => $value)
          {
              $userData->where($field, '=', $value);
          }
      }
      $userData->with([
         'userDataRelation1',
         'userDataRelation2',
      ]);
      $userData = $userData->get();
      return Response::json($userData);
  }

This is my JavaScript code :

<script src='https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js'></script>
     <script>
     $(document).ready(function(){
         var url = 'http://example.com/app/public/index.php/api/userdata?filters[id]=633';
         $.getJSON(url, function(response){
             console.log(response);
         });
     });
     </script>

Why does the AJAX request always return a "Connection Reset" ? What is the possible cause for this ? How to fix the problem ?

Thanks in advance.

DavidHyogo
  • 2,838
  • 4
  • 31
  • 48
user1578301
  • 85
  • 2
  • 7

0 Answers0