[英]ajax jquery post example error 503
當我單擊運行按鈕時,在chrome控制台中顯示此錯誤,不發出任何警告
POST http://mysite/gd/add.php 503 (Service Unavailable)
的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"; ?>
我已經在本地環境中嘗試過您的代碼,它工作正常。 由於Web服務器(正在運行網站)而導致的503錯誤原因當前由於服務器的暫時超載或維護而無法處理HTTP請求。 這意味着這是一個暫時性狀況,經過一段時間的延遲后會緩解。 處於此狀態的某些服務器也可能只是拒絕套接字連接,在這種情況下,由於套接字創建超時,可能會生成不同的錯誤。
user2511140:我添加此代碼以顯示錯誤。我的服務器正忙並顯示錯誤。我更改了服務器,問題已解決
$.ajax({ url: 'add.php',
type: 'post',
data: {'q': ''},
success: function(output) {
alert(output);},
error: function (request, status, error) {
alert(request.responseText);},
});
}
所以我知道它已經很舊了,但是我只是在從事wordpress項目時解決了這個問題。 我收到了相同的錯誤消息,因為在抬頭(www.url.de/admin-ajax.ph)中編寫的admin-ajax-腳本的Url和從(加載數據的url之間有區別www.urx.de/ajax.php)
我認為您應該使用http://mysite/gd/add.php
或gd/add.php
URL gd/add.php
$.ajax({ url: 'http://mysite/gd/add.php',
data: {'q': ''},
type: 'post',
success: function(output) {
alert(output);}
});
如果以上代碼不起作用。 請檢查您的.htaccess
文件。
您當前的頁面是a.php
並且您向add.php
發送ajax請求,因此檢查它們是否都在同一目錄中?
如果是這樣,請嘗試遵循,否則請嘗試絕對HTTP路徑。
$.ajax({ url: './add.php',
data: {'q': ''},
type: 'POST',
success: function(output) {
alert(output);
}
});
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.