0

Possible Duplicate:
Using value passed to php by jQuery.getJSON

Hi I have this code which is passing data through:

var output = [];
$.getJSON(
    'DisplayMap.php',
    { runDate : $('input[name="date"]').val() },
    function(data) {
        for (var i in data.b) {
            output.push(new google.maps.LatLng(data.b[i].Ya, data.b[i].Za));
        }
    }
);

My question is, how would I handle that data and assign it to a php variable. Would I have to decode it?

Thanks in advance

Community
  • 1
  • 1
Matt Jameson
  • 217
  • 1
  • 8
  • 21
  • `var_dump($_GET, $_POST);` – zerkms Jan 09 '13 at 00:00
  • If `$('input[name="date"]').val()` does not return JSON, you are not sending JSON (I don't see any JSON anywhere else in your code). `runDate` will contain a normal value which you access the usual way, i.e. via `$_GET`. – Felix Kling Jan 09 '13 at 00:01

1 Answers1

1

You will be able to access it via

$_GET['runDate'];

Side note: For Google Maps API, don't access Ya and Za directly. They are not always consistently named. Instead, use .lat and .lng attribute getters

For example:

new google.maps.LatLng(data.b[i].lat, data.b[i].lng);
maček
  • 76,434
  • 37
  • 167
  • 198