我有增加了新的數據通過jQuery的數據庫的頁面上的表單。它工作正常,但有時服務器胡扯了,我得到一個500(內部服務器錯誤),但那是因爲我的服務器太爛。jQuery的:處理內部服務器錯誤響應
的問題是,我有時會收到服務器錯誤的PHP使得除了數據庫後,而是獲得成功的消息,我得到的錯誤,即使除了已經取得進展。那麼我該如何去解決這個問題,以確保PHP在出現錯誤時不會添加數據?
[是的,我最終將轉換到新的服務器,但沒有服務器是完美]
這裏的腳本:
$.ajax({
type: "POST",
url: "/clase/do-add",
data: $("#add").serialize(),
dataType: "json",
timeout: 8000,
beforeSend: function() {
var icon = '<p class="loading-add"></p>'; // loading icon
$('form#add').append(icon);
},
success: function(data) {
if (data.error == true) { // php returns error = true if name is invalid
alert('Invalid name.');
$('form#add').find('p').remove();
} else {
// make the addition
}
},
error: function() {
$('form#add').find('p').remove();
alert('Error. Try again.');
}
});
是因爲你的服務器太爛或者你的**服務器端代碼太爛了嗎? – 2011-01-05 14:11:30
是你的服務器嗎?你有shell嗎? – jAndy 2011-01-05 14:17:05
這是服務器,當我加載頁面時,我不斷收到各種字符 - ><ÄWÝrÔ¾¾Þ}Å''7»äÏk''¡lh – Norbert 2011-01-05 14:28:02