AJAX innerHTML and image not displaying

JavaScript and client side scripting.

Moderator: General Moderators

Post Reply
snowDeveloper
Forum Newbie
Posts: 2
Joined: Thu Nov 17, 2005 12:33 am

AJAX innerHTML and image not displaying

Post by snowDeveloper »

Hello,

I am having a problem with setting a div with innerHTML,
using AJAX and your basic php backend.

The problem is when I make a AJAX request the image is
not displayed. After setting the innerHTML.

Examples can be seen at:

http://usatoday.snocountry.com/displayi ... ode=303007
http://usatoday.snocountry.com/displayi ... snowreport

If you click 'snow report' or 'resort info' at the top you will see the transition
but the images do not show up.

Has anyone encountered this? I am imagine it is a simple fix, with the problem
induced by late night coding...

Thanks in Advance

Michael
http://www.snocountry.org
User avatar
RobertGonzalez
Site Administrator
Posts: 14293
Joined: Tue Sep 09, 2003 6:04 pm
Location: Fremont, CA, USA

Post by RobertGonzalez »

In your links, their appears to be unparsed php vars ($permcode):

Code: Select all

<div id="primarySnoNav">
      <b><a class="snoLink" href="#" onclick="javascript:processLinkUI('resortinfo|{$permcode}'); return false;"><font face="Arial" size="2" color="#0099FF"> resort</font> <font face="Arial" size="2" color="#666666"> info</font> </a> </b>
      &#9474;

      <b><a class="snoLink" href="#" onclick="javascript:processLinkUI('snowreport|{$permcode}'); return false;"> <font face="Arial" size="2" color="#0099FF">snow</font> <font face="Arial" size="2" color="#666666">  conditions </font></a> </b>
      &#9474;
These are the two links that you are having problems with, correct? Maybe look at the script that is outputing this to see why these vars are echoing out as vars rather than the var value.
User avatar
n00b Saibot
DevNet Resident
Posts: 1452
Joined: Fri Dec 24, 2004 2:59 am
Location: Lucknow, UP, India
Contact:

Post by n00b Saibot »

I have a hunch he put them in single quotes :)
snowDeveloper
Forum Newbie
Posts: 2
Joined: Thu Nov 17, 2005 12:33 am

Problem fixed...

Post by snowDeveloper »

Thanks,

Your posts were correct and lead me down
the path to a couple other such errors.

I know coding after 11:00pm is not a good
idea....

Michael
http://www.snocountry.org
User avatar
wtf
Forum Contributor
Posts: 331
Joined: Thu Nov 03, 2005 5:27 pm

Post by wtf »

innerHTML will overwrite everything that already included in that block

Code: Select all

<div id="ha"><img src="what.jpg"></div>


ha.innerHTML = "some text";


<div id="ha">some text</div>
could that be your problem?
Post Reply