Guest User

How to use ajax to show php in a modal pop up

a guest
Mar 20th, 2012
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.47 KB | None | 0 0
  1. $('a.poplight[href^=#]').click(function() {
  2. var popID = $(this).attr('rel'); //Get Popup Name
  3. var popURL = $(this).attr('href'); //Get Popup href to define size
  4.  
  5. //Pull Query & Variables from href URL
  6. var query= popURL.split('?');
  7. var dim= query[1].split('&');
  8. var popWidth = dim[0].split('=')[1]; //Gets the first query string value
  9.  
  10. //Fade in the Popup and add close button
  11. jQuery('#' + popID).fadeIn(200).css({ 'width': Number( popWidth ) });
  12.  
  13.  
  14. //Define margin for center alignment (vertical horizontal) - we add 80px to the height/width to accomodate for the padding
  15. var popMargTop = ($('#' + popID).height() + 80) / 2;
  16. var popMargLeft = ($('#' + popID).width() + 80) / 2;
  17.  
  18. //Apply Margin to Popup
  19. jQuery('#' + popID).css({
  20. 'margin-top' : -popMargTop,
  21. 'margin-left' : -popMargLeft
  22. });
  23.  
  24. //Fade in Background
  25. $('body').append('<div id="fade"></div>'); //Add the fade layer to bottom of the body tag.
  26. $('#fade').css({'filter' : 'alpha(opacity=80)'}).fadeIn(); //Fade in the fade layer - .css({'filter' : 'alpha(opacity=80)'}) IE
  27.  
  28. return false;
  29.  
  30.  
  31. });
  32.  
  33. //Close Popups and Fade Layer
  34. $('a.close, #fade, .cancel').live('click', function() { //When clicking on the close or fade layer...
  35. $('#fade , .popup_block').fadeOut(function() {
  36. $('#fade, a.close').remove(); //fade them both out
  37. $('form').clearForm();
  38. });
  39. return false;
  40. });
  41.  
  42. <a href="#?w=480" rel="whatever" class="poplight"><input type="button" class="button" value="update"/></a>
Advertisement
Add Comment
Please, Sign In to add comment