To Pavel: the context is different: I want to pass data to javascript function. The function is not in a waiting state ! I execute the function from PHP with echo. To Jake: I transform a string in array. How to execute a javascript function from PHP with parameters coded with json_encode ?
On 22 oct, 13:37, Pavel Janíček <[email protected]> wrote: > Hi in my development, I used example of > this:http://code.google.com/apis/maps/articles/phpsqlajax.html > > So, I am extracting my database to XML file and then loading it via > javascript > > And you can extend the XML to your needs ... take look at my export > for examplehttp://adresar.bohyne.net/phpsqlajax_genxml.php > > On Oct 22, 3:29 am, Jake <[email protected]> wrote: > > > On Oct 21, 10:12 am,phicarre<[email protected]> wrote: > > > > Hi, > > > I extract in PHP a list of points (= polygon) from a mysql database. > > > $points = $row['Points']; > > > > The $points format is (val1,val2),(val3,val4), ... > > > > Now I would like to pass these points to a javascript function. I do: > > > echo "my_function($points);"; > > > > from client side: > > > function my_function(pt) > > > { > > > ... > > > > } > > > > I receive a message "undefined" for pt ! > > > > I tried this: > > > - I transform $points in array: $myarray > > > - I define $myjarray=json_encode($myarray); > > > - I call echo "my_function($myjarray);"; > > > > Its "better" but I don't see how to extract the couple of coordinates > > > pt.length return 1 !!!! > > > > Finally, do you know a good method to pass a list of points (lat+lng) > > > from PHP to a javascript function without using XML format ? > > > That's strange. I do that all the time, I just use json_encode and > > pass the data to a Javascript function. And this is data including > > points, html, and all kinds of other things. It always gives me the > > correct length. I've found it to be a very simple and efficient way to > > pass data. > > > You may want to do a print_r and make sure the indexes of the arrays > > you are passing in all are sequential and start with zero. > > > Could you describe what you mean by this? > > "I transform $points in array: $myarray" > > > What exactly are you "transforming?" --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Google Maps API" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/google-maps-api?hl=en -~----------~----~----~----~------~----~------~--~---
