Thursday 15 August 2013

javascript - call a $.getJSON and sending URL parameter -



javascript - call a $.getJSON and sending URL parameter -

i have page next url test.php?city=paris , have php script (getdata.php) executes sql request , homecoming json object. execute request need parameter city in url. phone call getdata.php script :

var ville = "<?php echo $_get['ville']?>"; $.getjson("bat/getdata.php", {ville: ville}, function( info ) { console.log(data); });

i don't think best way send url parameter php script. think?

you should not echo arbitrary info script. have opened cross-site scripting attacks.

you can around problem json-encoding data, compatible javascript.

var ville = <?php echo json_encode($_get['ville']); ?>;

javascript php jquery

No comments:

Post a Comment