Solved

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

Posted on 2008-06-13
5
170 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
ID: 21777850
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
ID: 21777858
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
ID: 21777901
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
ID: 21777924
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
ID: 21778613
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Styling your websites can become very complex. Here I'll show how SASS can help you better organize, maintain and reuse your CSS code.
This article discusses how to create an extensible mechanism for linked drop downs.
Viewers will learn one way to get user input in Java. Introduce the Scanner object: Declare the variable that stores the user input: An example prompting the user for input: Methods you need to invoke in order to properly get  user input:
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

895 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

11 Experts available now in Live!

Get 1:1 Help Now