Do more on the web, with a fast and secure browser!

Download Opera browser with:

  • built-in ad blocker
  • battery saver
  • free VPN
Download Opera

Ajax net::ERR_SPDY_PROTOCOL_ERROR

  • Hello!
    I've moved my site to new server (ubuntu 16.04 + nginx + php7.2) and got errors "POST https://food-tracker.ru/foods net::ERR_SPDY_PROTOCOL_ERROR" when it make ajax requests.
    There are no errors at FireFox and Internet Explorer browsers! And at previous server with debian7+nginx+php5 all worked fine with latest Opera too. But now latest Opera is not working with the site. Can You help me? How to solve this problem?
    Thank You!

  • @gydrus The page seems to load fine here, does this cause any problem to access the site?

    A search for 'Ajax net::ERR_SPDY_PROTOCOL_ERROR' returned several results, did you try to check some of them?

  • @leocg Yes, page loads fine! but after authorization on site some ajax requests are not works. (
    Yes, i've tryed all recommendations given by google (clear cache, reset connections and so on), but they was not successfull (

  • Yeah! I've found the solution!
    There is a request code example:

    $.ajax({
    	url: 'https://food-tracker.ru/foods',
    	type: 'POST',
    	dataType: 'JSON',
    	data: {term: 'rjk'},
    	success: function (data) {console.log(data);}
    });
    

    And there was server code:

    protected function returnJSON($data) {
        header('text/html; charset=utf-8');
        echo json_encode($data);
        die(0);
    }
    

    The solution is to change line header('text/html; charset=utf-8'); to header('Content-type: application/json; charset=utf-8');

    So, right working code is:

    protected function returnJSON($data) {
        header('Content-type: application/json; charset=utf-8');
        echo json_encode($data);
        die(0);
    }
    

    Thanks for your attention!

    P.S. But one question i still have: why was it working fine before, and brokes when just hosting changed?