google maps server not responding (PHP/html/json)

Hi, I created a google maps server using php,json and html. The map is displayed but the server doesn’t respond when I try to update the location. I use HTTP GET request and the data is echoed to be saved to a text file but the server doesn’t change the location. The code works fine on my local apache server. I got the code from the internet and I’m a beginner in the field. I have a feeling that the json file is not working properly maybe?

My code:

<?php if (!empty($_GET["latitude"]) && !empty($_GET["longitude"])) { function getParameter($par, $default = null){ if (isset($_GET[$par]) && strlen($_GET[$par])) return $_GET[$par]; elseif (isset($_POST[$par]) && strlen($_POST[$par])) return $_POST[$par]; else return $default; } $file = 'gps.txt'; $lat = getParameter("latitude"); $lon = getParameter("longitude"); $person = $lat.",".$lon."\ "; echo " DATA:\ Latitude: ".$lat."\ Longitude: ".$lon; if (!file_put_contents($file, $person, FILE_APPEND | LOCK_EX)) echo "\ \\t Error saving Data\ "; else echo "\ \\t Data Save\ "; } else { ?>
<!-- Load Jquery -->

<script language="JavaScript" type="text/javascript" src="jquery-1.10.1.min.js"></script>

<!-- Load Google Maps Api -->

<!-- IMPORTANT: change the API v3 key -->

<script src=""></script>


<!-- Initialize Map and markers -->

<script type="text/javascript">
	var myCenter=new google.maps.LatLng(25.10045,55.17805);
	var marker;
	var map;
	var mapProp;

	function initialize()
		mapProp = {

	function mark()
		map=new google.maps.Map(document.getElementById("googleMap"),mapProp);
	    var file = "gps.txt";
	    $.get(file, function(txt) { 
	        var lines = txt.split("\


			for (var i=0;i<lines.length;i++){
				var words=lines[i].split(",");
				if ((words[0]!="")&&(words[1]!="")){
					marker=new google.maps.Marker({
						  position:new google.maps.LatLng(words[0],words[1]),
					map.setCenter(new google.maps.LatLng(words[0],words[1]));


	google.maps.event.addDomListener(window, 'load', initialize);
<?php echo '
	<!-- Draw information table and Google Maps div -->

		<center><br />
			<b> SIM908 GPS position DEMO </b><br /><br />
			<div id="superior" style="width:800px;border:1px solid">
				<table style="width:100%">
						<td>Speed OTG</td>
						<td id="time">'. date("Y M d - H:m") .'</td>
						<td id="sat"></td>
						<td id="speed"></td>
						<td id="course"></td>
                                                     <td id="latitude"></td>
			<br /><br />
			<div id="googleMap" style="width:800px;height:700px;"></div>
<?php } ?>

I have two questions for you:

  1. Can you please properly format your code? Formatting multiple lines of code is best done by adding a line with three backticks (```) above and below your code block. Right now, I can’t properly see which part of your message is code and which isn’t, let alone read the code.
  2. What happens exactly when you try this. Do you see any response from the Maps API? Do you see errors on the Javascript console?

Thanks for your reply. I know now the problem is with the javascript code part. My question now is, does infinityfree run javascripts normally?

@maryammagdy said:
Thanks for your reply. I know now the problem is with the javascript code part. My question now is, does infinityfree run javascripts normally?

Javascript runs in a visitor’s browser, not on the server. I’m not sure we could make it work differently if we tried.