passing variables to a javascript file using php

Discussion in 'Programming/Scripts' started by badben, Aug 29, 2007.

  1. badben

    badben New Member

    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
     
  2. falko

    falko Super Moderator Howtoforge Staff

    People could download the .js file and see the coordinates there, too.
     
  3. blu3ness

    blu3ness New Member

    eh, just write a php script that outputs javascript source file and then include that PHP file in your head?
     
  4. Ben

    Ben Active Member Moderator

    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?
     
  5. blu3ness

    blu3ness New Member

    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.
     

Share This Page