Skip to content

Instantly share code, notes, and snippets.

@fahidjavid
Created December 16, 2020 09:14
Show Gist options
  • Save fahidjavid/b213461d38a3b307a2ea58d9e7dd3267 to your computer and use it in GitHub Desktop.
Save fahidjavid/b213461d38a3b307a2ea58d9e7dd3267 to your computer and use it in GitHub Desktop.
ajaxurl JS variable can be used for the WP admin ajax URL in any JS file of the RealHomes theme now.
var add_to_favorite_options = {
type : 'post',
url : ajaxurl, // This is how we can use the 'ajaxurl' variable for the WordPress ajax URL.
data : {
action: 'add_to_favorite',
property_id : propertyID,
},
success: function(response) {
if('false' !== response) {
$(favorite_link).addClass('hide');
$(span_favorite).delay(200).removeClass('hide');
}
}
};
$.ajax(add_to_favorite_options);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment