Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/mercurial/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
使用ajax打印php页面_Php_Jquery_Ajax_Echo - Fatal编程技术网

使用ajax打印php页面

使用ajax打印php页面,php,jquery,ajax,echo,Php,Jquery,Ajax,Echo,我经常使用Ajax来传递JSON数据,但实际上我有一个问题 我想将我页面的php转换到另一个页面,并且只使用ajax打印它 Php: 如果您只想在其他页面打印上述代码的输出,只需使用.load()方法。它与phpinclude()相同,请尝试从另一个页面加载此脚本。我已经试过了,它可以用了 var default_content=“” $(“#页面内容”).onClick(函数加载页面(url) { url=url.replace(“#page”,”); $('加载').css('可见性','

我经常使用Ajax来传递JSON数据,但实际上我有一个问题

我想将我页面的php转换到另一个页面,并且只使用ajax打印它

Php:


    如果您只想在其他页面打印上述代码的输出,只需使用
    .load()方法。它与php
    include()

    相同,请尝试从另一个页面加载此脚本。我已经试过了,它可以用了 var default_content=“”

    $(“#页面内容”).onClick(函数加载页面(url)
    {
    url=url.replace(“#page”,”);
    $('加载').css('可见性','可见');
    $.ajax({
    类型:“POST”,
    url:“YourPHP.php”,
    数据:“页面=”+url,
    数据类型:“html”,
    成功:功能(msg){
    如果(parseInt(msg)!=0)
    {
    $('#pageContent').html(msg);
    $('加载').css('可见性','隐藏');
    }
    }
    });
    }
    ……在这里做点什么
    
    您正在寻找类似的产品吗?
    <ul  class="thumbnails biblio sortable">
                                    <?php
                                        $reponse = $bdd->query("SELECT id_gallery,nom_gallery,link_gallery,img_gallery
                                        FROM gallery where id_gallery='$gallery'");
    
    
                                        $donnees = $reponse->fetchAll();
                                        for($k=0;$k<count($donnees);$k++){
                                            $id_gallery=$donnees[$k]['id_gallery'];
                                            $nom_gallery=$donnees[$k]['nom_gallery'];
                                            $link_gallery=$donnees[$k]['link_gallery'];
                                            $img_gallery=$donnees[$k]['img_gallery'];
    
                                            $link_gallery = explode(",", $link_gallery);
    
                                            $longueur=count($link_gallery);
                                            //echo "longueur: ".$longueur;
                                            for($j=0;$j<$longueur;$j++){
                                                $id=$link_gallery[$j];
                                                $reponse = $bdd->query("SELECT nom_fichier,id_fichier
                                                                        FROM fichier
                                                                        where id_fichier = '$id' ");
    
    
                                                $donnees = $reponse->fetchAll();
                                                if(count($donnees) != 0){
                                                    $nom_fichier=$donnees[0]['nom_fichier'];
                                                    $id_fichier=$donnees[0]['id_fichier'];
    
                                                    if($j % 4 == 0 && $j !=0){
                                                        echo"</ul>";
                                                        echo"<ul  class='thumbnails biblio sortable'>";
                                                    }
                                                    //if($)
                                                    echo"<li class='span3 ui-state-default info' style='overflow:hidden;' data-click='".$id_fichier."'>";
                                                    //str+="<input id='"+data[i].id_gallery +"' type='checkbox' value='option'>";
                                                    echo"<ul class='thumbnail-actions'>";
                                                    echo"<li><a href='#' title='Edit photo'><span class='icon-pencil'></span></a></li>";
                                                    //str+="<li><a href='upload/download.php?filename="+dataSplited[i].nom_fichier+"' title='Download photo'><span class='icon-download'></span></a></li>";
                                                    echo"<li><a class='delete' id='href-".$id_fichier."' href='".$nom_fichier."' data-click='".$id_fichier."'  title='Delete photo'><span class='icon-trash'></span></a></li>";
                                                    echo"</ul>";
                                                    echo"<a class='thumbnail' href='#' ><img alt='Image 34' src='upload/uploads/".$nom_fichier."' style='width:200px;height:200px;'  ></a>";
                                                    echo"</li>";
                                                    }
    
                                            }
    
    
    
                                        }
                                    ?>
                                </ul>
    
      $("#pageContent").onClick(function loadPage(url)
      {
    url=url.replace('#page','');
    
    $('#loading').css('visibility','visible');
    
    $.ajax({
        type: "POST",
        url: "YourPHP.php",
        data: 'page='+url,
        dataType: "html",
        success: function(msg){
    
            if(parseInt(msg)!=0)
            {
                $('#pageContent').html(msg);
                $('#loading').css('visibility','hidden');
            }
        }
    
    });
    
       }
     </script>
     <div id ="pageContent">
    ......do something  here
     </div>