jquery弹出窗口不能从Ajax工作

时间:2012-11-11 11:55:37

标签: php javascript jquery firefox

此代码在页面上完美运行并打开弹出窗口, 但是我从Ajax调用它它不起作用。 我试过,调用一些简单的函数fff(),甚至它不能从ajax工作。它写的没有定义。

这是弹出功能:

$(document).ready(

function(){
//open popup
 $(document).on("click", ".pop", function(){

var url = $(this).attr('name');

 $("#"+url).fadeIn(1000);
 positionPopup(this);
});

//close popup
$(document).on("click", ".close", function(){

  var url = $(this).attr('name');


$("#"+url).fadeOut(500);
});
});

function popupFun() 
{
    $(".pop").click(function(){

    var url = $(this).attr('name');

     $("#"+url).fadeIn(1000);
     positionPopup(this);
    });

    //close popup
    $(".close").click(function(){

      var url = $(this).attr('name');


        $("#"+url).fadeOut(500);
    });
}


//position the popup at the center of the page
function positionPopup(element){

  var url = $(element).attr('name');


  if(!$("#"+url).is(':visible')){

    return;
  } 



  $("#"+url).css({
      left: ($(window).width() - $('#'+url).width()) / 2,
      top: ($(window).width() - $('#'+url).width()) / 7,
      position:'absolute'
  });


}


//maintain the popup at center of the page when browser resized
$(window).bind('resize',positionPopup);

</script>
<style>
.overlay_form{
    position: absolute;
    border: 0px solid gray;
    padding: 0px;
    background: ;
    width: 400px;
    height: 500px;
}
.pop{
    display: inline;
    border: 0px solid gray;
    width: 65px;
    text-align: center;
    padding: 6px;
    border-radius: 5px;
    text-decoration: none;
    margin: 0 auto;
}
</style>

从ajax调用此代码:

<script type="text/javascript" src="include/jquery-popup/jquery-1.6.1.min.js"></script>

<?
require_once('include/popup_functions.php');
?>
<script type="text/javascript" >
alert('0');
function fff()
{
alert('hi');
}

</script>
<?

echo "<br><table style='width:80%' class='blue-table' border=2 >";

$result_fields_list=array("name","care_giver_kind_id","service","branch","cg_profile");
foreach($res_list as $name=>$det)
{

  echo "<tr>";
       foreach($result_fields_list as $field)
       {
           echo "<td>";


           if($field=="branch"&&$det['branch_id'])
                   {

                       $j++;

            ?>
            <nobr><a href='#' onclick="alert(1);fff();  "          id="pop" class="pop" name='<?='overlay_form'.$j?>'  ><?=get_bc_branch_name($det['branch_id'])?></a></nobr>

            <div class="overlay_form" id='<?="overlay_form".$j?>' style="display:none">

                <?
                  $_GET['b_id']=$det['branch_id'];
                  include('bc_branch_profile.php');
                 ?>
            </div>

            <?

                   }

           echo "&nbsp </td>";
       }

   echo "</tr>";
}
echo "</table>";

}

谢谢!!

0 个答案:

没有答案