我有一個GoDaddy Linux託管計劃,我有兩個關於此計劃的網站。最近這兩個網站在AJAX調用中遇到問題,特別是AJAX在第5次AJAX調用中不起作用!4次嘗試後GoDaddy Linux服務器和AJAX呼叫失敗
我聯繫了GoDaddy支持,他們說我必須將服務器操作系統改爲Windows。這是一個可怕的解決方案。我正在尋找其他選項。
是否有任何額外的jQuery AJAX編碼,我應該添加這個工作?如果我將操作系統轉換爲Windows,一切正常嗎?或者我應該改變一些事情?
這裏是jQuery的AJAX我用:
function nextPhoto(){
$('#prevPhoto').show();
$('#photoApear').css('margin-left','0%');
if($('#photoPlaceSpan').text()==$('#photoCountSpan').text()){
$('#nextPhoto').hide();
}
else{
$('#nextPhoto').show();
}
var photo=$('#photoIdSpan').text();
var id=$('#adidSpan').text();
var place=$('#photoPlaceSpan').text();
var username=$('#usernameSpan').text();
var dataString='username='+username+'&photo='+photo+'&id='+id+'&place='+place;
$.ajax({
type:"POST",
url:"nextphoto.php",
data:dataString,
beforeSend: function(){
$('#photoApear').html('<img src="../images/ajax-loader.gif" width="75" height="75" style="margin-top:200px;" />');
},
success: function(html){
$('#photoApear').html(html);
place++;
$('#photoPlaceSpan').html(place);
if($('#photoPlaceSpan').text()==$('#photoCountSpan').text()){
$('#nextPhoto').hide();
}
else{
$('#nextPhoto').show();
}
}
});}
$('#prevPhoto')
是一個 「上一頁」 按鈕
$('#nextPhoto')
是 「下一個」 按鈕
$('#photoApear')
是含有照片
$('#photoPlaceSpan')
是當前圖像的「訂單號」的範圍
這個函數在幾個星期前工作的很好,但現在它在4或5次按下「next」或「prev」按鈕之後不起作用。
這裏的PHP處理Ajax:
<?php
error_reporting(0);
require_once("../Connections/localhost.php");
$photo=mysql_real_escape_string($_POST['photo']);
$username=mysql_real_escape_string($_POST['username']);
$id=mysql_real_escape_string($_POST['id']);
$ind=mysql_real_escape_string($_POST['place']);
$ind++;
$sqlNew="SELECT *
FROM photos
WHERE username='$username' AND
ad_id='$id' AND
place='$ind'";
$infoNew=mysql_fetch_array(mysql_query($sqlNew));
$image = '../user_photos/'.$infoNew[photo].'';
// Set the width of the area and height of the area
$inputwidth = 640;
$inputheight = 480;
// Get the width and height of the Image
list($width,$height) = getimagesize($image);
// So then if the image is wider rather than taller,
// set the width and figure out the height
if (($width/$height) > ($inputwidth/$inputheight)) {
$outputwidth = $inputwidth;
$outputheight = ($inputwidth * $height)/ $width;
}
// And if the image is taller rather than wider,
// then set the height and figure out the width
elseif (($width/$height) < ($inputwidth/$inputheight)) {
$outputwidth = ($inputheight * $width)/ $height;
$outputheight = $inputheight;
}
// And because it is entirely possible that the image could be the exact same
// size/aspect ratio of the desired area, so we have that covered as well
elseif (($width/$height) == ($inputwidth/$inputheight)) {
$outputwidth = $inputwidth;
$outputheight = $inputheight;
}
$coverwidth=900;
$coverheight=500;
print '<img src="'.$image.'" width="'.$outputwidth.'" height="'.$outputheight.'"/>';
?>
而且我也爲這個問題有點研究,有人建議我把header_status(200);我不知道這意味着什麼,以及如何去做任何想法?
沒有辦法知道你的jQuery和Ajax在做什麼,你的代碼作爲響應被髮送有多沉重,請求的頻繁程度以及同時發生的用戶數量,我們無法幫助你。 – Prix
請少用questionmarks = /,也不是很好的描述問題。但改變操作系統不會幫助,不。 +我們可能需要php代碼以及... –
@Prix對不起,我添加了代碼 –