我使用jQuery 1.3.2/1.4.2的問題AJAX檢索數據:問題檢索AJAX數據
它與IE 7/8
它失敗,FF 3.5/3.6時,Chrome 5.0.375.70
該件的jQuery代碼是非常基本的:
$.get('http://myhost/someurl',function(data) {
if (data) {
alert('data is: ' + data);
} else {
alert('no data');
}
});
除IE之外的所有測試過的瀏覽器都屬於ELSE。 我比較HTTP標頭與IE和FF回報,我看不出有什麼可能導致問題(「測試」實際上是由服務器返回的數據):我使用Wireshark檢查
[with IE]
HTTP/1.1 200 OK
Date: Tue, 22 Jun 2010 10:01:32 GMT
Server: Apache/2.2.8 (Ubuntu) PHP/5.2.4-2ubuntu5.10 with Suhosin-Patch
X-Powered-By: PHP/5.2.4-2ubuntu5.10
Expires: Thu, 19 Nov 1981 08:52:00 GMT
Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0
Pragma: no-cache
Content-Length: 4
Keep-Alive: timeout=15, max=100
Connection: Keep-Alive
Content-Type: text/html
test
[with FF]
HTTP/1.1 200 OK
Date: Tue, 22 Jun 2010 10:01:54 GMT
Server: Apache/2.2.8 (Ubuntu) PHP/5.2.4-2ubuntu5.10 with Suhosin-Patch
X-Powered-By: PHP/5.2.4-2ubuntu5.10
Set-Cookie: PHPSESSID=1777838b6006566fee273bd329463d57; path=/
Expires: Thu, 19 Nov 1981 08:52:00 GMT
Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0
Pragma: no-cache
Content-Length: 4
Keep-Alive: timeout=15, max=100
Connection: Keep-Alive
Content-Type: text/html
test
和HTTP響應是格式良好的(最後一個標題和內容之間有2 x「\ r \ n」)。使用Firefox,如果我使用HTTPwatch檢查響應,它會向我顯示內容中的「測試」。但是,如果我用螢火蟲看它,我什麼都看不到。使用Chrome瀏覽器的定位工具的行爲相同。
我是否智障?
謝謝。
「測試」是有效的html數據。 if語句也是有效的。 正確的答案是帕特里克的,因爲我的確在從系統測試並向外部服務器發送ajax請求。 – Max 2010-06-22 13:56:57