dongzhao5834 2013-06-10 14:12
浏览 26

jquery对话框中的数据库数据

Ok, i tried it with jquery ajax to achieve the same. But now the system always shows the first id. It doesn't matter at which edit_subscriber image i click. This is what i did:

Jquery code:

    jQuery(".edit_subscriber").click( function() {


    jQuery('.dialog-modal').dialog({
    modal: true,
    open: function ()
    {
        jQuery.ajax({
            async: false,
            type: 'get',
            url: nieuwsbrief.editsubscriber,
            data: 'ajax=&subscriber_id=' + jQuery('.edit_subscriber').prop('id'),
                success: function(data) {
                    jQuery('.dialog-modal').html(data);
                }
        });
    },
    close: function ()
    {

    },         
    height: 400,
    width: 600,
    title: 'Ajax Page'
});
    return false;
});

html code:

echo '<div class="dialog-modal" title="Basic modal dialog" style="display: none;"></div>';

edit_subcriber.php:

<?php
 include_once $_SERVER['DOCUMENT_ROOT'] . '/www/wordpress/wp-config.php';
 include_once $_SERVER['DOCUMENT_ROOT'] . '/www/wordpress/wp-load.php';
 include_once $_SERVER['DOCUMENT_ROOT'] . '/www/wordpress/wp-includes/wp-db.php';

 global $wpdb;

 echo $_GET['subscriber_id'];

 ?>
  • 写回答

1条回答 默认 最新

  • du229908 2013-06-10 14:18
    关注

    The issue with the script is, you are using same id for all dialog-models, and when you are clicking on the edit_subscriber, it is picking the dialog form the id, and as you are picking form id, it will always get the first element with the id.

    Multiple element with same id is not valid.

    So you can try this.

    Just replace this code

    echo '<div id="dialog-modal" title="Basic modal dialog" style="display: none;">
           Naam: <input type = "text" name = "subscriber_name" id = "'.$abonnee->subscriber_id.'" value = "'.$abonnee->subscriber_name.'"> <br />
    </div>';
    

    with this

     echo '<div class="dialog-modal" title="Basic modal dialog" style="display: none;">
           Naam: <input type = "text" name = "subscriber_name" id = "'.$abonnee->subscriber_id.'" value = "'.$abonnee->subscriber_name.'"> <br />
    </div>';
    

    and change js function to :

    jQuery(".edit_subscriber").click( function() {
        $(this).closest('tr').next().dialog({
            modal: true,
            open: function (){},
            close: function (){},         
            height: 400,
            width: 600,
            title: 'Ajax Page'
        });
    });
    

    As you are placing div after tr which is also not valid markup.

    评论

报告相同问题?

悬赏问题

  • ¥15 下图接收小电路,谁知道原理
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度
  • ¥30 关于#r语言#的问题:如何对R语言中mfgarch包中构建的garch-midas模型进行样本内长期波动率预测和样本外长期波动率预测
  • ¥15 ETLCloud 处理json多层级问题
  • ¥15 matlab中使用gurobi时报错
  • ¥15 这个主板怎么能扩出一两个sata口
  • ¥15 不是,这到底错哪儿了😭
  • ¥15 2020长安杯与连接网探