{"id":3039,"date":"2014-03-15T02:03:33","date_gmt":"2014-03-15T02:03:33","guid":{"rendered":"https:\/\/unknownerror.org\/index.php\/2014\/03\/15\/uncaught-referenceerror-my-function-is-not-defined-collection-of-common-programming-errors\/"},"modified":"2014-03-15T02:03:33","modified_gmt":"2014-03-15T02:03:33","slug":"uncaught-referenceerror-my-function-is-not-defined-collection-of-common-programming-errors","status":"publish","type":"post","link":"https:\/\/unknownerror.org\/index.php\/2014\/03\/15\/uncaught-referenceerror-my-function-is-not-defined-collection-of-common-programming-errors\/","title":{"rendered":"Uncaught ReferenceError: my function is not defined-Collection of common programming errors"},"content":{"rendered":"<p>I am trying to build a CakePHP application which will allow a user to update their address information, and then store the new lat\/lon in the database. I am using Google&#8217;s geocoder to retrieve lat\/lon information but my function isn&#8217;t working. I have almost no experience with Javascript so I am not sure what I have done wrong. My code is kind of an amalgamation of what I have seen around the internet. Please, if someone could advise me, that would be great.<\/p>\n<p>Here is my geocode function:<\/p>\n<pre><code>\n\nfunction getLatLong(address){\n  var geo = new google.maps.Geocoder;\n  var address =;\n  geo.geocode({'address':address},function(results, status){\n          if (status == google.maps.GeocoderStatus.OK) {\n            return results[0].geometry.location;\n            alert('The address is' + address);\n          } else {\n            alert(\"Geocode was not successful for the following reason: \" + status);\n          }\n\n   });\n\n  }\n\n<\/code><\/pre>\n<p>Above my html, here is the script to call it onLoad of the page:<\/p>\n<pre><code>\nif(window.attachEvent) {\nwindow.attachEvent('onload', getLatLong());\n} else {\nif(window.onload) {\n    var curronload = window.onload;\n    var newonload = function() {\n        curronload();\n        getLatLong();\n    };\n    window.onload = newonload;\n} else {\n    window.onload = getLatLong();\n}\n}\n\n<\/code><\/pre>\n<p>I have in the head of my document:<\/p>\n<pre><code> \n<\/code><\/pre>\n<p>When I load the page and inspect it with chrome, I see<\/p>\n<pre><code>Uncaught ReferenceError: getLatLong is not defined   (anonymous function)1:89\n1:106      Uncaught SyntaxError: Unexpected identifier\n<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>I am trying to build a CakePHP application which will allow a user to update their address information, and then store the new lat\/lon in the database. I am using Google&#8217;s geocoder to retrieve lat\/lon information but my function isn&#8217;t working. I have almost no experience with Javascript so I am not sure what I [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-3039","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/3039","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/comments?post=3039"}],"version-history":[{"count":0,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/3039\/revisions"}],"wp:attachment":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/media?parent=3039"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/categories?post=3039"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/tags?post=3039"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}