Solved

What part of this image variable needs to be setup client side vs server side?

Posted on 2008-06-13
5
169 Views
Last Modified: 2011-10-19
Hello,

I'm trying to display an image in my Google Maps Infowindow. To this end i need a little further help setting up this variable:

var info = '<div id="info" style="text-align:left";><img src="travel_pics/"' + id + '"/x_info.jpg" width=150 height=100><h3>' + title + '</h3><br>' + date + '</div>';

In particular i'm having difficulty with this part:
<img src="travel_pics/"' + id + '"/x_info.jpg"

I understand there's an issue because Javascript doesn't know what images are on the server, so this needs to be defined server-side in my php.

Please can you tell me what specifically i need to define in my php script and what needs to go in my javascript to make this work?
(i have attached both my javascript 'index.php' and my php script 'read.php' for your reference).


Many thanks


index.php.txt
read.php.txt
0
Comment
Question by:Daniish
  • 3
5 Comments
 
LVL 1

Expert Comment

by:SideFX250
Comment Utility
readme.php.txt has an error:
$info_pic = "travel_pics/" . id . "/x_info.jpg";
should be:
$info_pic = "travel_pics/" . $id . "/x_info.jpg";
(a $ in front of $id)

0
 
LVL 82

Accepted Solution

by:
hielo earned 400 total points
Comment Utility
currently you have:
travel_pics/"' + id + '"/x_info.jpg

the double quotes adjacent to the slashes should NOT be there. Try:
var info = '<div id="info" style="text-align:left";><img src="travel_pics/' + id + '/x_info.jpg" width=150 height=100><h3>' + title + '</h3><br>' + date + '</div>';
0
 
LVL 1

Assisted Solution

by:SideFX250
SideFX250 earned 100 total points
Comment Utility
It's very easy to debug this with FireFox with the firebug extension enabled.  If you're using IE, try Fiddler.

In the "console" section of firebug, you'll be able to see your requests and responses for XMLHttp (AJAX).  They won't show up on the web page as errors.

The firebug console or fiddler would've shown the parse error noted above.


0
 
LVL 1

Expert Comment

by:SideFX250
Comment Utility
I also recommend the "Web Developer" extension for firefox.  It allows you to easily inspect elements and even modify them inline.
0
 

Author Comment

by:Daniish
Comment Utility
Thanks to both of you, although SideFX250 your 1st post is incorrect. If i use the dollar sign then Firebug reports that $id is undefined!
0

Featured Post

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
HTML5 has deprecated a few of the older ways of showing media as well as offering up a new way to create games and animations. Audio, video, and canvas are just a few of the adjustments made between XHTML and HTML5. As we learned in our last micr…
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

743 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now