Advertisement
bradtrivers

WordPress AJAX - Trigger function on front end click

Nov 5th, 2012
581
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. jQuery(document).ready(function($j) {
  2.  
  3. $j(document).on("click", "#openPersonChangeRequest", function(){
  4.     var thisLink = $j(this);
  5.     thisLink.css('display','none');    
  6.     var personChangeRequestDiv = $j('#personChangeRequest');
  7.     personChangeRequestDiv.html('Loading Update Form...');
  8.     personChangeRequestDiv.slideToggle('slow');      
  9.     var data = {
  10.       action: 'loadPersonUpdateForm'
  11.     };
  12.     // on user side ajaxurl is defined using localization handle marconfAjax.ajaxurl
  13.     $j.post(marconfAjax.ajaxurl, data, function(response) {
  14.       personChangeRequestDiv.html(response); //add form to post
  15.     });
  16.  
  17.     return false;
  18.   });
  19.  
  20. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement