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 使用rabbitMQ 消息队列作为url源进行多线程爬取时,总有几个url没有处理的问题。
  • ¥85 maple软件,solve求反函数,出现rootof怎么办?
  • ¥15 求chat4.0解答一道线性规划题,用lingo编程运行,第一问要求写出数学模型和lingo语言编程模型,第二问第三问解答就行,我的ddl要到了谁来求了
  • ¥15 Ubuntu在安装序列比对软件STAR时出现报错如何解决
  • ¥50 树莓派安卓APK系统签名
  • ¥15 maple软件,用solve求反函数出现rootof,怎么办?
  • ¥65 汇编语言除法溢出问题
  • ¥15 Visual Studio问题
  • ¥20 求一个html代码,有偿
  • ¥100 关于使用MATLAB中copularnd函数的问题