【问题标题】:No image, and no popup window没有图像,也没有弹出窗口
【发布时间】:2010-09-25 02:46:52
【问题描述】:

我有一个 ajax 应用程序,它不会显示图像,也不会从存储在文件中的 html 弹出窗口。

这是我用于弹出窗口的代码:

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=''>

【问题讨论】:

    标签: php javascript html ajax


    【解决方案1】:

    您的 HTML 看起来无效 - 您有:

    <style ty
      <p><strong>Location</strong></p> float: right;
    
      <p><strong>Conditions</strong></p> margin: 0px;
    

    首先&lt;style&gt; 标签没有关闭(1. 开始标签甚至不完整,2. 你没有结束标签)-当我使用 Firefox/Firebug 查看 HTML 时,它正在处理HTML 的其余部分在该标记内,因此不显示它。

    您还可以将float: right; 之类的样式声明混合在 HTML 中,而不是在样式标记中。

    【讨论】:

    • html 是从 php 生成的……但是 php 有什么问题?
    • 这个问题可能是由 PHP 文件中的 HTML 引起的
    【解决方案2】:

    您确实需要 Firefox/Firebug 来帮助调试它。您的脚本错误可能导致页面停止加载,因此您的图像未显示。

    【讨论】:

    • 我目前无法访问 firebug,并且鉴于我发布的错误似乎更多的是在 php 方面?当我自己调用页面时,浏览器中没有报告脚本错误
    【解决方案3】:

    如果您使用innerHTML 替换通过Ajax 传递此响应,它将不起作用。你需要解析回调中的&lt;script&gt;...&lt;/script&gt;eval()

    一般来说,您应该在服务器端使用一些不错的 PHP 框架,在客户端使用 Javascript 库。否则你很快就会开始从头开始重写你的程序来清理它,只是发现它几乎没有任何改进。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2015-09-18
      • 2014-04-16
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多