views:

155

answers:

3

Hello, I hava an ajax application that will not display an image, or make a popup window from html stored in a file.

This is the code I am usiong for the popup:

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

And the resulting 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&gt;
</div>

The img src is a valid location and opens in a browser fine, but will not display in the page. I get a script error which does not state any details.

edit: When calling the file alone, not as part of the application, the resulting html file generates a link that creates a popup window, but the source shows that nothing is being assigned to the window:

child1.document.write("");

I made changes to the img src line:

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

Which results in the html returning:

<img src=''>
+1  A: 

You really need to get Firefox/Firebug to help debug this. It's possible that your script error is causing the page to stop loading and thus your image is not displayed.

tvanfosson
I dont have access to firebug at the moment, and given what I posted the error seems to be more in the php side of things?? When I call the page by itself there is no script error reported in the browser
Joshxtothe4
A: 

If you carry this response through Ajax using innerHTML substitution it won't work. You need to parse the <script>...</script> in callback and eval() it.

And in general, you should be using some decent PHP framework on server side and Javascript library on client side. Otherwise you will soon start rewriting your program from scratch to clean it up, just to find out that it's hardly any better.

Michał Rudnicki
+1  A: 

Your HTML looks invalid - you have:

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

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

Firstly the <style> tag is not closed (1. the opening tag is not even complete and 2. you don't have a closing tag) - when I look at the HTML using Firefox/Firebug, it is treating the rest of the HTML as being within that tag and therefore not displaying it.

Also you have style declarations like float: right; mixed within the HTML and not within a style tag.

Tom Haigh
the html is generated from the php though...what is the problem in the php?
Joshxtothe4
The problem is probably cause by HTML within your PHP file
Tom Haigh