Search code examples
javascriptphpjqueryajaxhttp-status-code-503

ajax jquery post example error 503


When i click run button show this error in chrome console and don't alert anything

POST http://mysite/gd/add.php 503 (Service Unavailable) 

enter image description here

index.php

<html>
<head>   
 <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
</head>
<body >
 <script>
function go(){  
$.ajax({ url: 'add.php',
         data: {'q': ''},
         type: 'post',
         success: function(output) {
         alert(output);}
});
}
 </script>
 <button onclick="go();">Run</button>
</body>
</html>

add.php

<?php echo "Hello"; ?>

Solution

  • I have tried your code in local environment, it is working fine. The reason for 503 error because of the Web server (running the Web site) is currently unable to handle the HTTP request due to a temporary overloading or maintenance of the server. The implication is that this is a temporary condition which will be alleviated after some delay. Some servers in this state may also simply refuse the socket connection, in which case a different error may be generated because the socket creation timed out.
    user2511140 : I add this code to show errors.my server is to busy and show error.i changed server and problem solved

    $.ajax({ url: 'add.php',
             type: 'post',
             data: {'q': ''},
             success: function(output) {
             alert(output);},
        error: function (request, status, error) {
            alert(request.responseText);},
    });
    }