Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

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

Posted on 2008-06-13
5
Medium Priority
?
185 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 1600 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 400 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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

Boost your ability to deliver ambitious and competitive web apps by choosing the right JavaScript framework to best suit your project’s needs.
Today, the web development industry is booming, and many people consider it to be their vocation. The question you may be asking yourself is – how do I become a web developer?
Viewers will learn about arithmetic and Boolean expressions in Java and the logical operators used to create Boolean expressions. We will cover the symbols used for arithmetic expressions and define each logical operator and how to use them in Boole…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.
Suggested Courses

886 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