I am trying to call the getPointOnMap function in an onclick event and give it a json object as a parameter.
Here are some sample code:
$.ajax({ type: "POST", url: "/getResult.json", success: function(result) { var html = ''; for (var i = 0; i < result.length; i++) { var obj = result[i]; html += "<input type='checkbox' onClick='getPointOnMap(" + obj + ")'/>" + obj.address + "<br>"; } $("#myDiv").append(html); } });
there is a getPointOnMap function
function getPointOnMap(object) { map.addMarker({ lat: object.lattitude, lng: object.longtitude, click: function(e) { alert('You clicked in this marker'); } }); }
firebug output (also in the name question):
SyntaxError: missing] after list of items
getPointOnMap([object Object])
What should I do to pass the correct object?
source share