2012-06-07 78 views
0

因此,我試圖使用加載函數將div的內容從一個網頁拖到我們的移動頁面上的div。在我的桌面瀏覽器上,一切都很好。代碼拉我需要的所有信息完美。但出於某種原因,在我的android瀏覽器上進行測試時,它不會提取信息。相反,屏幕左下方有一些文字說「加載」,但沒有加載。下面是我使用的網站上的代碼片段:Jquery加載功能在手機瀏覽器中不起作用

<script src="http://code.jquery.com/jquery-1.6.4.min.js"></script> 

<script src="http://code.jquery.com/mobile/1.1.0/jquery.mobile-1.1.0.min.js"></script> 

<script>$(document).ready(function(){ $('#newevents').load('http://www.kobebistro.com/5/special.php #events'); });</script> 

你可以檢查出full site/source code

我一直停留在過去的幾天。任何幫助將不勝感激!

回答

0

問題(至少你爲什麼看到'加載'文本)是由於jQuery Mobile的CSS文件沒有被添加到你的頁面。您在底部看到的「加載」文本實際上是jQuery Mobile頁面轉換/加載。

添加以下樣式錶鏈接到你的頁面的頂部:

<link rel="stylesheet" href="http://code.jquery.com/mobile/1.1.0/jquery.mobile-1.1.0.min.css" /> 
<script src="http://code.jquery.com/jquery-1.6.4.min.js"></script> 
<script src="http://code.jquery.com/mobile/1.1.0/jquery.mobile-1.1.0.min.js"></script> 

或者隱藏使用下面的CSS規則到現有的樣式表:

.ui-loader { 
    display: none; 
} 

我已經安裝該工程爲例我在兩個桌面(在Firefox和Chrome上測試)和Android Mobile瀏覽器(2.3)上:
http://www.jonwarner.net/stackoverflow/10940849/mobile/index.htm

我也建議您通過網頁上的解剖下面看看網頁製作:
http://jquerymobile.com/demos/1.1.0/docs/pages/page-anatomy.html

你看到任何警告,如果您使用下面的代碼?

<script>$(document).ready(function(){ alert('document ready called'); });</script> 

從上面移動的,考慮增加一個回調,並檢查響應:

$("#newevents").load("http://www.kobebistro.com/5/special.php#events", function(response, status, xhr) { 
    alert(JSON.stringify(xhr)); 
}); 

的jsfiddle設置,希望能夠幫助您解決問題:

http://jsfiddle.net/X3B6t/1/

+0

耶,在桌面和移動瀏覽器上彈出顯示「文檔已準備好調用」。 – RKhog

+0

你的代碼調用來自同一個域的load()(只是不同的頁面)? – JonWarnerNet

+0

是的,相同的域...不同的文件夾雖然 – RKhog

相關問題