Pass a variable with downloadUrl

708 views
Skip to first unread message

Coachy

unread,
Sep 30, 2009, 5:46:03 PM9/30/09
to Google Maps JavaScript API v3
Hello

Is it possible to pass any variable with this method
downloadUrl("phpsqlajax_genxml2.php, function(data) { ...
}


I need to send a variable to phpsqlajax_genxml2.php for the SQL
request.

Thanks for your help.

Stéphane

pamela (Google Employee)

unread,
Sep 30, 2009, 5:51:15 PM9/30/09
to google-map...@googlegroups.com
Hi Stephane-

To send it via get, you can append it to the end of the URL:
"phpsqlajax_genxml2.php?bla=10&foo=20"

To send it via POST, you need to modify that function and pass the
url-encoded parameters in the .send() function. See here:
http://www.openjs.com/articles/ajax_xmlhttp_using_post.php

- pamela

Coachy

unread,
Sep 30, 2009, 6:12:44 PM9/30/09
to Google Maps JavaScript API v3
Thanks Pam for your answer,

I tried that but it doesn't works :
downloadUrl("phpsqlajax_genxml2.php?client=22", function(data) {

In phpsqlajax_genxml2.php, i write that :
$client = $_REQUEST['client'];
$query = "SELECT * FROM markers WHERE client = '$client'";

What's wrong ?




On 30 sep, 23:51, "pamela (Google Employee)" <pamela...@gmail.com>
wrote:
> > Stéphane- Masquer le texte des messages précédents -
>
> - Afficher le texte des messages précédents -

pamela (Google Employee)

unread,
Sep 30, 2009, 6:16:29 PM9/30/09
to google-map...@googlegroups.com
Not sure what $_REQUEST does, I always use $_GET. Can you try that?

Coachy

unread,
Sep 30, 2009, 6:47:12 PM9/30/09
to Google Maps JavaScript API v3
Ok, you are right, it works now.

Last question.
I would like to pass this variable with php
Like that : downloadUrl("phpsqlajax_genxml2.php?client=".$client,
function(data) {
I know it's not the good syntax.

How can i do to pass a php variable ?


On 1 oct, 00:16, "pamela (Google Employee)" <pamela...@gmail.com>
wrote:
> >> - Afficher le texte des messages précédents -- Masquer le texte des messages précédents -

Coachy

unread,
Sep 30, 2009, 6:58:29 PM9/30/09
to Google Maps JavaScript API v3
I have found the solution, i give it :

var clientjs = '<?php echo $client; ?>';
downloadUrl("phpsqlajax_genxml2.php?client=" + clientjs,function(data)
{ ....

Frank Munthali

unread,
Mar 26, 2017, 4:59:16 PM3/26/17
to Google Maps JavaScript API v3, stephan...@gmail.com

Hi, great solution. Where can i download your complete code?
Reply all
Reply to author
Forward
0 new messages