php - 如何使用ajax在模态弹出窗口中显示php

标签 php html jquery

你好 :) 我正在尝试弄清楚如何在我使用的 jquery 脚本中通过 ajax 获取一些内容。我正在尝试自定义此脚本以满足我的需要,它非常简单明了:

$('a.poplight[href^=#]').click(function() {
 var popID = $(this).attr('rel'); //Get Popup Name
 var popURL = $(this).attr('href'); //Get Popup href to define size

 //Pull Query & Variables from href URL
 var query= popURL.split('?');
 var dim= query[1].split('&');
 var popWidth = dim[0].split('=')[1]; //Gets the first query string value

 //Fade in the Popup and add close button
 jQuery('#' + popID).fadeIn(200).css({ 'width': Number( popWidth ) });


 //Define margin for center alignment (vertical   horizontal) - we add 80px to the height/width to accomodate for the padding
 var popMargTop = ($('#' + popID).height() + 80) / 2;
 var popMargLeft = ($('#' + popID).width() + 80) / 2;

 //Apply Margin to Popup
 jQuery('#' + popID).css({
     'margin-top' : -popMargTop,
     'margin-left' : -popMargLeft
 });

 //Fade in Background
 $('body').append('<div id="fade"></div>'); //Add the fade layer to bottom of the body tag.
 $('#fade').css({'filter' : 'alpha(opacity=80)'}).fadeIn(); //Fade in the fade layer - .css({'filter' : 'alpha(opacity=80)'}) IE

 return false;


});

 //Close Popups and Fade Layer
 $('a.close, #fade, .cancel').live('click', function() { //When clicking on the close or fade layer...
     $('#fade , .popup_block').fadeOut(function() {
         $('#fade, a.close').remove();  //fade them both out
      $('form').clearForm();
 });
     return false;
 });

它正在调用一个隐藏的 div。我想只调用一个 php 文件,它包含所有内容。这是 html 的样子:

<a href="#?w=480" rel="whatever" class="poplight"><input type="button" class="button" value="update"/></a>

有什么想法吗?提前致谢:)

好的,我尝试了 jQuery UI 的对话框...我必须说,这有点令人沮丧... 我知道很难遵循别人的编码,但实际上我可以调整几乎所有内容,除了如何使用此代码获取数据并将其显示在弹出窗口中,因为 href 调用的是模态大小,而不是任何实际内容

所以我又回到了这个哈哈

最佳答案

你为什么不使用 jquery ui 的 modal dialog相反(良好的代码质量)。然后你通过$.get()获得内容

关于php - 如何使用ajax在模态弹出窗口中显示php,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4482786/

相关文章:

php - 从 mysql 查询回显字符串 - PHP

javascript - 如何计算一类的 div,即一类的容器 div 的子级?

html - 在全屏背景中居中对齐内容?

javascript - 如何使用从 Google Analytics 检索的数据并将其显示在 Google 图表中

javascript - Knockoutjs 模板 : How to use 1 object array for 2 DOM elements after filtering that array by some property?

php - 休会框架,选择查询

java - 在 Java 和 PHP 之间传递长字符串?

php - URL 不接受字母数字参数 - Yii2-app-basic

jquery - 如何选择容器中的可见元素?

javascript - 意外的标识符 : jQuery