Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/446.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
Javascript 使用jQuery和ajax在表中编辑列_Javascript_Jquery_Html_Ajax - Fatal编程技术网

Javascript 使用jQuery和ajax在表中编辑列

Javascript 使用jQuery和ajax在表中编辑列,javascript,jquery,html,ajax,Javascript,Jquery,Html,Ajax,我有一个静态表,希望更新数据。这是我想要实现的一个示例: <p>X-editable: create editable column in table.<br> As pk is unique in each row, you should put it in data-pk attribute. </p> <div style="margin: 150px"> <table id="users" class="table ta

我有一个静态表,希望更新数据。这是我想要实现的一个示例:

<p>X-editable: create editable column in table.<br>
 As pk is unique in each row, you should put it in data-pk attribute.  
</p>
<div style="margin: 150px">
    <table id="users" class="table table-bordered table-condensed">
        <tr><th>#</th><th>name</th><th>age</th></tr>
        <tr>
            <td>1</td>
            <td><a href="#" data-pk="1">Mike</a></td>
            <td>21</td>       
        </tr>

        <tr>
            <td>2</td>
            <td><a href="#" data-pk="2">John</a></td>
            <td>28</td>       
        </tr>        

        <tr>
            <td>3</td>
            <td><a href="#" data-pk="3">Mary</a></td>
            <td>24</td>       
        </tr>        

    </table>    
</div>
我尝试了完全相同的脚本,但仍然不起作用

<p>X-editable: create editable column in table.<br>
 As pk is unique in each row, you should put it in data-pk attribute.  
</p>
<div style="margin: 150px">
    <table id="users" class="table table-bordered table-condensed">
        <tr><th>#</th><th>name</th><th>age</th></tr>
        <tr>
            <td>1</td>
            <td><a href="#" data-pk="1">Mike</a></td>
            <td>21</td>       
        </tr>

        <tr>
            <td>2</td>
            <td><a href="#" data-pk="2">John</a></td>
            <td>28</td>       
        </tr>        

        <tr>
            <td>3</td>
            <td><a href="#" data-pk="3">Mary</a></td>
            <td>24</td>       
        </tr>        

    </table>    
</div>
以下是我导入的脚本:

<script type='text/javascript' src='http://code.jquery.com/jquery-git.js'></script>
<script type='text/javascript' src="//netdna.bootstrapcdn.com/twitterbootstrap/2.2.1/js/bootstrap.min.js"></script>
<script type='text/javascript' src="http://vitalets.github.com/x-editable/assets/x-editable/bootstrap-editable/js/bootstrap-editable.js"></script>
<script type='text/javascript' src="http://vitalets.github.com/x-editable/assets/mockjax/jquery.mockjax.js"></script>


<link rel="stylesheet" type="text/css" href="/css/normalize.css">
<link rel="stylesheet" type="text/css" href="/css/result-light.css">
<link rel="stylesheet" type="text/css" href="//netdna.bootstrapcdn.com/twitterbootstrap/2.2.1/css/bootstrap-combined.min.css">  
<link rel="stylesheet" type="text/css" href="http://vitalets.github.com/x-editable/assets/x-editable/bootstrap-editable/css/bootstrap-editable.css">    
<p>X-editable: create editable column in table.<br>
 As pk is unique in each row, you should put it in data-pk attribute.  
</p>
<div style="margin: 150px">
    <table id="users" class="table table-bordered table-condensed">
        <tr><th>#</th><th>name</th><th>age</th></tr>
        <tr>
            <td>1</td>
            <td><a href="#" data-pk="1">Mike</a></td>
            <td>21</td>       
        </tr>

        <tr>
            <td>2</td>
            <td><a href="#" data-pk="2">John</a></td>
            <td>28</td>       
        </tr>        

        <tr>
            <td>3</td>
            <td><a href="#" data-pk="3">Mary</a></td>
            <td>24</td>       
        </tr>        

    </table>    
</div>
HTML代码:

<p>X-editable: create editable column in table.<br>
 As pk is unique in each row, you should put it in data-pk attribute.  
</p>
<div style="margin: 150px">
    <table id="users" class="table table-bordered table-condensed">
        <tr><th>#</th><th>name</th><th>age</th></tr>
        <tr>
            <td>1</td>
            <td><a href="#" data-pk="1">Mike</a></td>
            <td>21</td>       
        </tr>

        <tr>
            <td>2</td>
            <td><a href="#" data-pk="2">John</a></td>
            <td>28</td>       
        </tr>        

        <tr>
            <td>3</td>
            <td><a href="#" data-pk="3">Mary</a></td>
            <td>24</td>       
        </tr>        

    </table>    
</div>
X-可编辑:在表中创建可编辑列。
由于pk在每一行中都是唯一的,所以应该将其放在数据pk属性中。

<p>X-editable: create editable column in table.<br>
 As pk is unique in each row, you should put it in data-pk attribute.  
</p>
<div style="margin: 150px">
    <table id="users" class="table table-bordered table-condensed">
        <tr><th>#</th><th>name</th><th>age</th></tr>
        <tr>
            <td>1</td>
            <td><a href="#" data-pk="1">Mike</a></td>
            <td>21</td>       
        </tr>

        <tr>
            <td>2</td>
            <td><a href="#" data-pk="2">John</a></td>
            <td>28</td>       
        </tr>        

        <tr>
            <td>3</td>
            <td><a href="#" data-pk="3">Mary</a></td>
            <td>24</td>       
        </tr>        

    </table>    
</div>
#姓名 1. 21 2. 28 3. 24

尝试使用相同的代码,但没有显示JSFIDLE是如何做到的!请问有什么帮助吗

是否有javascript错误?//netdna.bootstrapcdn.com/twitterbootstrap/2.2.1/js/bootstrap.min.js有问题吗?它返回404未找到。请尝试更改为//netdna.bootstrapcdn.com/twitter-bootstrap/2.2.1/js/bootstrap.min.jsHi,谢谢您的回复。GEMI-似乎没有任何javascript错误。kubedan-我已经改变了,但是仍然不像JSFIDLE那样显示。您的代码不工作或者看起来不像JSFIDLE?(css文件有问题)看起来像是?尝试将URL
//netdna.bootstrapcdn.com/twitter bootstrap/2.2.1/js/bootstrap.min.js
更改为
http://netdna.bootstrapcdn.com/twitter-bootstrap/2.2.1/js/bootstrap.min.js
<p>X-editable: create editable column in table.<br>
 As pk is unique in each row, you should put it in data-pk attribute.  
</p>
<div style="margin: 150px">
    <table id="users" class="table table-bordered table-condensed">
        <tr><th>#</th><th>name</th><th>age</th></tr>
        <tr>
            <td>1</td>
            <td><a href="#" data-pk="1">Mike</a></td>
            <td>21</td>       
        </tr>

        <tr>
            <td>2</td>
            <td><a href="#" data-pk="2">John</a></td>
            <td>28</td>       
        </tr>        

        <tr>
            <td>3</td>
            <td><a href="#" data-pk="3">Mary</a></td>
            <td>24</td>       
        </tr>        

    </table>    
</div>