Javascript/jQuery newbie - need to pass variables to a function

I have this button:

<a id="m_location" href="#" data-role="button" data-icon="search" data-latitude="<?php echo $mLatitude; ?>" data-longitude="<?php echo $mLongitude; ?>">Help me find this</a>

And I need to pass the data-longitude and data-latitude variables to a javascript function:

						$('#m_location').click(function() {
							var mlatlng = new google.maps.LatLng($('#m_location').data('latitude'), $('#m_location').data('longitude'));
							$('#map_canvas').gmap('search', { 'location': mlatlng }, function(results, status) {
								if ( status === 'OK' ) {
									$('#to').val(results[0].formatted_address);
								}
							});
						});

The above code doesn’t work though, and nothing happens in the form field (#to) when I click. Help?

Btw, I don’t have to do this through data-attributes, I simply need to add the variables to the button, and then pass them to the function and run the function when the button is clicked. The page may contain many different buttons with different values that need to be passed on click.

try using attr():

var mlatlng = new google.maps.LatLng($('#m_location').attr('data-latitude'), $('#m_location').attr('data-longitude'));

Thanks, that didn’t work either. Basically, nothing is happening when I click the link.