admin 管理员组文章数量: 1086019
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)
index.php
<html>
<head>
<script src=".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"; ?>
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)
index.php
<html>
<head>
<script src="http://ajax.googleapis./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"; ?>
Share
Improve this question
asked Nov 6, 2013 at 8:03
user2511140user2511140
1,6963 gold badges26 silver badges32 bronze badges
4
- You are using php in cgi and php is not working/crashed – user133408 Commented Nov 6, 2013 at 8:05
- 1 if you type in your browser mysite/gd/add.php does it work? – Dmitry Dvornikov Commented Nov 6, 2013 at 8:08
- How i can get data from php page through ajax? – user2511140 Commented Nov 6, 2013 at 8:09
- one time alert and one time show error – user2511140 Commented Nov 6, 2013 at 8:11
4 Answers
Reset to default 1I 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);},
});
}
so i know it is old, but i just solved this problem while working on a wordpress project. I got the same error message, because there was a difference between the Url of the admin-ajax - script, written in the header(www.url.de/admin-ajax.ph) - and the url to load the data from (www.urx.de/ajax.php)
Your current page is a.php
and you send ajax request to add.php
, so check whether they both are in same directory or not?
If so then try following or else try absolute HTTP path.
$.ajax({ url: './add.php',
data: {'q': ''},
type: 'POST',
success: function(output) {
alert(output);
}
});
I think you should call with http://mysite/gd/add.php
or gd/add.php
URL
$.ajax({ url: 'http://mysite/gd/add.php',
data: {'q': ''},
type: 'post',
success: function(output) {
alert(output);}
});
If above code is not working. Please check your .htaccess
file.
本文标签: javascriptajax jquery post example error 503Stack Overflow
版权声明:本文标题:javascript - ajax jquery post example error 503 - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.roclinux.cn/p/1744073175a2528861.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论