Jump to content

joycecwj

New Members
  • Posts

    7
  • Joined

  • Last visited

    Never

Everything posted by joycecwj

  1. sorry sorry. is like how to run a json function. its need any function call? example : function save(){ var finalpoint=marker.getPoint(); //alert (finalpoint); // alert(finalpoint); // var JSONObject = new Object; var data = finalpoint; data[data.length]={name:"data",value:data[0]}; //alert(data); /*var data = $("#add-point :input").serializeArray(); data[data.length] = { name: "lng", value: finalpoint[0] }; data[data.length] = { name: "lat", value: finalpoint[1] }; alert(data.value);alert(data.value);*/ // var dataString = $.toJSON(finalpoint); /*$.ajax({ type: "POST", url: URL, cache:false, data: values, dataType:'json', success: function(json) {*/ $("#add-point").submit(function(){ $.post($("#add-point").attr('action'),data, function(json){ alert (data); //$("#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"); return false; }); } oni need to write save(); to execute it? understand wat i mean?
  2. to run json function is it need a json function call? i read alot example all the json function start with $(document).ready(function(){ if i dun wan to do that my json function will run?
  3. :'( can you help me check?? i have no idea anymore... i'm newbie i think bout tis part 2 days d..T.T and its quite urgent... thank..
  4. how bout if i replace the line from $.post('em.php',js, function(json){ to $.post($("#add-point").attr('action'),data, function(json){ ??
  5. the php code or java? but when i load the page there is no error on page...
  6. 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. :'(
×
×
  • 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.