如何组合 id div 和 PHP ID



我不知道PHP和ID DIV的规范。这是我的问题:

我可以同时输入一个名为 #modal 的 ID DIVID PHP RETURN 吗?

while ( $contents_print = mysqli_fetch_array( $req_print ) ) {  
    echo'
        <div class="row print">
            <div class="col s12 m4">
              <div class="card">
                <div class="card-image">
                  <img data-tags="print" class="activator" src="../00_sources/images/upload/pic_min/' . $contents_print[ 'pic_min' ] . '" alt="' . $contents_print[ 'pic_min' ] . '">
                  <a href="#modal" class="btn-floating halfway-fab waves-effect waves-light primary-color-text modal-trigger"><i class="material-icons">add</i></a>
                </div>
                <div class="card-content">
                    <span class="card-title">'.$contents_print['nom_projet'].'</span>
                  <p>'.$contents_print['detail_projet'].'</p>
                </div>
              </div>
            </div>
         </div>';
}

这是我的jquery ajax代码:

$(document).ready(function(){
$('.materialboxed').materialbox();
 });
$( document ).ready( function () {
    $.ajax( {
            url: 'core/libs/contents-services.php?action=getFilterContent&id=3',
            type: "get",
            dataType: "html",
            success: function ( reponse ) {
                $( '#modal' ).html( reponse );
            }
        } );
    // the "href" attribute of the modal trigger must specify the modal ID that wants to be triggered
    $( '.modal' ).modal();
} );

在我的 ajax 代码中:行 url:"core/libs/content-services.php?action=getFilterContent&id=3",我必须使用 php/mysql 请求中的 id

我想做一个这样的链接:url: 'core/libs/content-services.php?action=getFilterContent&id='.$_GET['id'].',

我希望我清楚

感谢您的帮助

http://portfolio.rabahbook.fr 查看我的工作网站

据我了解,您从响应中获取一个 Id 并尝试将其分配给 ajax href。如果是这种情况,您可以执行以下操作(请注意url_id变量(。

var url_id =3;
$( document ).ready( function () {
$.ajax( {
  url: 'core/libs/contents-services.php?action=getFilterContent&id='+url_id,
  type: "get",
  dataType: "html",
  success: function ( reponse ) {
     $( '#modal' ).html( reponse );
     url_id  = response.url_id;/// get url id from response and assign it to 
     //your  href
  }
});
 // the "href" attribute of the modal trigger must specify the modal ID 
 //that wants to be triggered
 $( '.modal' ).modal();
 } );
 </script>
$('.post .modal-action').click(function(e){
    e.preventDefault();
    var id_projet= $(this).data('id_projet');
    var $hidennDiv = $('#' +id_projet);
    // do your ajax and whatever you want to do with the hidden div
    $.ajax( {
        url: 'core/libs/contents-services.php?action=getFilterContent&id='+id_projet,
        type: "get",
        dataType: "html",
        success: function ( reponse ) {
            $( '#modal' ).html( reponse );
            id_projet = reponse.id_projet;
        }
    } );
    $( '.modal' ).modal();
});

这对我有用

<a href="#modal" class="modal-action modal-trigger" data-id_projet="'.$contents_print[ 'id_projet' ].'"></a>

谢谢大家抽出时间向我道歉!

最新更新