Go Back   HowtoForge Forums | HowtoForge - Linux Howtos and Tutorials > Linux Forums > Programming/Scripts

Do you like HowtoForge? Please consider supporting us by becoming a subscriber.
Thread Tools Display Modes
Old 29th August 2007, 16:44
badben badben is offline
Senior Member
Join Date: Oct 2005
Location: Lancashire, UK
Posts: 103
Thanks: 0
Thanked 2 Times in 2 Posts
Default passing variables to a javascript file using php

I am trying to create a google maps application in php whereby a load of points appear on a map. The google maps api uses ajax and the coordinates can be entered using a seperate .js file or in the <head> section of the html page.

The coordinates are stored in my database (MySQL) and are dynamically extracted depending on what the user searches for.

However I don't want people to be able to look at the actual coordinates which they would be able to do if they were entered in the <head> section, I instead want them to be put in a seperate .js file.

My question is how do I dynamically get these coordinates from the database in a .js file?

I hope this question makes sense.

Ben Davies
Web Developer
Reply With Quote
Sponsored Links
Old 30th August 2007, 22:30
falko falko is offline
Super Moderator
Join Date: Apr 2005
Location: Lneburg, Germany
Posts: 41,701
Thanks: 1,900
Thanked 2,749 Times in 2,579 Posts

People could download the .js file and see the coordinates there, too.
Download the ISPConfig 3 Manual! | Check out the ISPConfig 3 Billing Module!

FB: http://www.facebook.com/howtoforge

nginx-Webhosting: Timme Hosting | Follow me on:
Reply With Quote
Old 14th September 2007, 22:23
blu3ness blu3ness is offline
Junior Member
Join Date: Aug 2007
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts

eh, just write a php script that outputs javascript source file and then include that PHP file in your head?
Reply With Quote
Old 14th September 2007, 22:27
Ben Ben is offline
Join Date: Jul 2006
Posts: 1,029
Thanks: 7
Thanked 62 Times in 56 Posts

well es both before posted, just output your data and that will result in a js code /file. but in both cases the user will be able to read the content of that js file.
IS there no other way to gather the data from google and pass the whole page, like a proxy app to the client?
Reply With Quote
Old 29th September 2007, 07:36
blu3ness blu3ness is offline
Junior Member
Join Date: Aug 2007
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts

So what are you trying to do with the javascript data.

You can always initiate an AJAX request,get some XML and parse it with javascript.
Reply With Quote


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Apache2 Freezes celtic Server Operation 31 28th May 2007 18:18
Chroot SSH + ISPConfig Norman Installation/Configuration 27 26th March 2007 04:40
Systemimager (rsync) doesn't copy all comedit HOWTO-Related Questions 11 19th January 2007 18:17
ubuntu ispconfig joomla .htaccess steve1084 General 8 6th January 2007 16:55
HotSaNIC domino Tips/Tricks/Mods 23 6th November 2006 06:19

All times are GMT +2. The time now is 04:05.

Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2014, vBulletin Solutions, Inc.