Sacconi69

cancella_prezzi_2.js

Oct 31st, 2024
212
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.83 KB | None | 0 0
  1. jQuery(document).ready(function($) {
  2. $('#target2').on('click', function() {
  3. if (confirm("Do you really want to delete prices?")) {
  4. $.ajax({
  5. url: my_ajax_obj.ajax_url, // WordPress AJAX URL
  6. type: 'POST',
  7. data: {
  8. action: 'reset_price_fields', // Custom action to be processed in PHP
  9. author_id: $(this).data('author-id') // Pass the author ID
  10. },
  11. success: function(response) {
  12. alert(response.message); // Show success message
  13. },
  14. error: function() {
  15. alert('Error resetting prices.'); // Show error message
  16. }
  17. });
  18. }
  19. });
  20. });
  21.  
  22. add_action( 'admin_enqueue_scripts', 'reset_price_fields' );
Advertisement
Add Comment
Please, Sign In to add comment