Skip to content

Instantly share code, notes, and snippets.

@rajucs
Created April 27, 2020 17:53
Show Gist options
  • Save rajucs/43f5e8a959eeb3019ea58559fc1972ea to your computer and use it in GitHub Desktop.
Save rajucs/43f5e8a959eeb3019ea58559fc1972ea to your computer and use it in GitHub Desktop.
jQuery(document).ready(function(){
// Ajax for make primary address -- my account page
jQuery(".class-name").click(function(){
let class_id = $(this).attr('class-id');
jQuery.ajax({ //ajax request
url: dsmAjax.ajaxurl,
type: "POST",
data: {
'action':'dsmGetCustomPostTypes',
'class_id' : class_id,
'security' : dsmAjax.ajax_nonce,
},
success:function(data) { //result
var json_data = jQuery.parseJSON(data);
var data = '<ul>';
$.each(json_data,function(key,value){
data+= "<li>"+v+"</li>";
})
data += '</ul>';
$("#post-types").append(data);
// alert(data);
},
error: function(errorThrown){
console.log(errorThrown);
}
});
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment