Jump to content

help...JSON.. urgent!


joycecwj

Recommended Posts

 function save(){
 var finalpoint=marker.getPoint();
 eval(finalpoint);
var js=json_encode(finalpoint);


				 $.post('em.php',js, function(json){
					//$("#add-point .error").fadeOut();
					if (json.status == "fail") {
						$("#add-point .error").html(json.message).fadeIn();
					}
					if (json.status == "success") {
						$("#add-point :input[name!=action]").val("");
						var location = json.data;
						alert(location);
					}
				}, "json");
			}

this is my javascript. i want to pass the finalpoint to php....but its didnt work...HELP~~~

 

$geocode=$_POST['finalpoint'];
	echo "here".$geocode;

        $chunks = spliti (",", $geocode);
	$lat= $chunks[0];
	$lng= $chunks[1];
	$query="UPDATE employer SET lat='$lat', lng='$lng' WHERE id='1' ;";
$res = mysql_query($query);

	if ($res) {
		success(array('lat' => $lat, 'lng' => $lng));
	} else {
		fail('Failed to add point.');
	}
	exit;
}

function map_query($query) {
	// Connect
	mysql_connect('localhost', 'root', '')
	    OR die(fail('Could not connect to database.'));

	mysql_select_db('map');
	return mysql_query($query);
}

function fail($message) {
	die(json_encode(array('status' => 'fail', 'message' => $message)));
}

function success($data) {
	die(json_encode(array('status' => 'success', 'data' => $data)));
}

here is the php. :'(

Link to comment
https://forums.phpfreaks.com/topic/159520-helpjson-urgent/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.