X-Editable数字类型未定义

时间:2014-07-04 13:08:15

标签: javascript php x-editable

我使用x可编辑。但是我只想输入数字,而min是0. max是100但是我得到了这样的结果。

http://localhost/bismillah/livetableedit/process.php?id=1&data=undefined&key=name

在数据中取消定义。

这是我的代码。

while($fetch = mysql_fetch_array($query))
                    {
                        if($i%2==0) $class = 'even'; else $class = 'odd';

                        echo'<tr class="'.$class.'">
                                <td>'.$no.'</td>
                                <td class="xedit" id="'.$fetch['id'].'" key="name" data-type="number" min="0" max="100">'.$fetch['name'].'</td>
                                <td class="xedit" id="'.$fetch['id'].'" key="details">'.$fetch['details'].'</td>
                                <td class="xedit" id="'.$fetch['id'].'" key="status">'.$fetch['status'].'</td>
                            </tr>'; 
                        $no++;                      
                    }

这是我的javascript代码

jQuery(document).ready(function() {  
    $.fn.editable.defaults.mode = 'popup';
    $('.xedit').editable();     
    $(document).on('click','.editable-submit',function(){
        var key = $(this).closest('.editable-container').prev().attr('key');
        var x = $(this).closest('.editable-container').prev().attr('id');
        var y = $('.input-sm').val();
        var z = $(this).closest('.editable-container').prev().text(y);



        $.ajax({
            url: "process.php?id="+x+"&data="+y+"&key="+key,
            type: 'GET',
            success: function(s){
                if(s == 'status'){
                $(z).html(y);}
                if(s == 'error') {
                alert('Error Processing your Request!');}
            },
            error: function(e){
                alert('Error Processing your Request!!');
            }
        });
    });

});

我尝试更改代码

<a href="#" class="xedit" data-type="number" id="'.$fetch['id'].'" key="name">'.$fetch['name'].'</a>

但同样的问题,任何想法?

注意:我从这里得到了这个

http://www.jqueryajaxphp.com/live-table-edit-using-jquery-ajax-and-php-twitter-bootstrap/

感谢

1 个答案:

答案 0 :(得分:0)

假设您的process.php正确无误,您只需将密钥更改为“key =”number“