2008-12-03 42 views
0

我有一個ajax應用程序不會顯示圖像,或者從存儲在文件中的html中創建一個彈出窗口。沒有圖像,也沒有彈出窗口

這是我usiong的彈出代碼:

echo '<script> 
function makewindows(){ 
child1 = window.open ("about:blank"); 
child1.document.write(' . json_encode($row2["ARTICLE_DESC"]) . '); 
child1.document.close(); 
} 
</script>'; 

還有生成的HTML

<script> 
function makewindows(){ 
child1 = window.open ("about:blank"); 
child1.document.write("<!-- +++++++++++++++++++++++++ Bitte \u00e4ndern Sie im eigenen Interesse nichts an diesem Code! ++++++++++++++++++++++++ -->\n<!-- +++++++++++++++++++++++++ Das kann massive Fehldarstellungen ihrer Auktion zur Folge haben! +++++++++++++++++++ -->\n<!-- +++++++++++++++++++++++++ ++++++++++++++++++++++++++ Ihr Supreme Team +++++++++++++++++++++++++++++++++++++++++ -->\n"); 
child1.document.close(); 
} 
</script><br /> 
<b>Notice</b>: Undefined index: CATEGORY in <b>C:\Programme\EasyPHP 2.0b1\www\get_auction.php</b> on line <b>39</b><br /> 
<div id='leftlayer'> 
    <strong>Article Number</strong> 220288560247 
    <p><strong>Article Name</strong></p> Ed Hardy Herren Shirt Rock & Roll Weiss XXL Neu & OVP 
    <p><strong>Subtitle</strong></p> 
    <p><strong>Username</strong></p> fashionticker1 
    <p><strong>Total Selling</strong></p> 1 
    <p><strong>Total Sold</strong></p> 0 
    <p><strong>Category</strong></p> 
    <p><strong>Highest Bidder</strong></p> 0 
    </div> 
<div class='leftlayer2'> 
    <strong>Current Bid</strong> 0.00 
    <p><strong>Start Price</strong></p> 49.00 
    <p><strong>Buyitnow Price</strong></p> 59.00 
    <p><strong>Bid Count</strong></p> 0 
    <p><strong>Start Date</strong></p> 1.10.2008 16:22:09 
    <p><strong>End Date</strong></p> 6.10.2008 16:22:09 
    <p><strong>Original End</strong></p> 6.10.2008 16:22:09 
    <p><strong>Auction Type</strong></p> 1 
</div> 
<div class='leftlayer2'> 
    <strong>Private Auction</strong></p> 0 
    <p><strong>Paypal Accepted</strong></p> 0 
    <p><strong>Auction Watched</strong></p> 0 
    <p><strong>Finished</strong></p> 1 
    <p><strong>Country</strong></p> 
<br> 
<br> 
<style ty 
    <p><strong>Location</strong></p> float: right; 

    <p><strong>Conditions</strong></p> margin: 0px; 

</div> 
<div class='leftlayer2'> 
    <strong>Auction Revised</strong></p> 0 
    <p><strong>Cancelled</strong></p> 0 
    <p><strong>Shipping to</strong></p> padding:5px; 

    <p><strong>Fee Insertion</strong></p> 0.00 
    <p><strong>Fee Final</strong></p> 0.00 
    <p><strong>Fee Listing</strong></p> 0.00 
    <p><a href='#' onclick='makewindows(); return false;'>Click for full description </a></p> 
</div><div id='rightlayer'>Picture Picture 
<img src=http://storage.supremeauction.com/flash/ebay2/10/49/76/10497654/13895964e.jpg> 
</div> 

的IMG SRC是一個有效的位置,並在瀏覽器中細打開,但不會顯示在頁面中。我得到一個腳本錯誤,沒有說明任何細節。

編輯:當單獨調用文件,而不是應用程序的一部分,生成的HTML文件生成創建一個彈出窗口的鏈接,但源表明,沒有什麼是被分配到窗口:

child1.document.write(""); 

我更改了IMG SRC行:

<img src='".$lastImg."'> 

這會導致HTML返回:

<img src=''> 

回答

1

你的HTML看起來無效的 - 你必須:

<style ty 
    <p><strong>Location</strong></p> float: right; 

    <p><strong>Conditions</strong></p> margin: 0px; 

首先在<style>標籤未關閉(1.打開標籤不完整的,甚至和2你沒有關閉標籤) - 當我使用Firefox/Firebug查看HTML,它將HTML的其餘部分視爲在該標記中,因此不會顯示它。

此外,您還可以在HTML中混合樣式聲明,如float: right;,而不是在樣式標記中。

+0

html是從php生成的,儘管...在php中有什麼問題? – 2008-12-04 11:04:57

1

你真的需要得到Firefox/Firebug來幫助調試。您的腳本錯誤可能導致頁面停止加載,因此您的圖像不會顯示。

+0

我目前沒有進入螢火蟲,並給予我發佈的錯誤似乎更多的是在PHP的一面?當我自己調用頁面時,瀏覽器中沒有報告腳本錯誤 – 2008-12-03 13:21:50

0

如果您通過使用innerHTML替換的Ajax來執行此響應,它將不起作用。你需要解析回調中的<script>...</script>eval()

一般來說,你應該在服務器端使用一些體面的PHP框架,在客戶端使用Javascript庫。否則,你很快就會開始重新編寫你的程序來清理它,只是爲了發現它幾乎沒有更好的。