Skip to content

Instantly share code, notes, and snippets.

@2Fwebd
Created February 5, 2019 22:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save 2Fwebd/0f8e147124709fa6435e16365a62255b to your computer and use it in GitHub Desktop.
Save 2Fwebd/0f8e147124709fa6435e16365a62255b to your computer and use it in GitHub Desktop.
/**
* Fetch the Members locations using AJAX
*
* The action sent to the WordPress router is: woffice_map_members
*/
fetchLocations: function () {
var self = this;
$.ajax({
url: this.url,
type: 'POST',
data: {
action: 'woffice_map_members',
_nonce: this.nonce,
},
success: function (data) {
if (data.length === 0) {
return;
}
// We parse it from JSON to an Array
var returnedMembers = JSON.parse(data);
// We don't add it if there is any error
if (returnedMembers.error !== undefined) {
return;
}
self.members = returnedMembers;
// Let's draw the markers
self.drawMarkers();
}
});
},
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment