【问题标题】:AJAX POST REQUEST using jquery使用 jquery 的 AJAX POST 请求
【发布时间】:2016-10-14 22:13:08
【问题描述】:

谁能帮我为这种情况创建一个 ajax 请求?如果我单击确定 ID,我想要。我只想更新它的内容并存储在数据库中。希望这里的任何人都可以帮助我。谢谢。

查看文件:

<tbody>
    <?php foreach ($ds_name as $dsname): ?>
    <tr>
        <td><div class="text-infoo<?= $dsname->id ?>"><?= $dsname->name ?></div></td>
        <td>
            <a href="#" id="edit<?= $dsname->id ?>"><span class="glyphicon glyphicon-pencil"></span></a>
            <a href="#" id="ok<?= $dsname->id ?>"><span class="glyphicon glyphicon-ok"></span></a>
            <a href="#"><span class="glyphicon glyphicon-remove"></span></a>
        </td>
    </tr>
    <?php endforeach; ?>
</tbody>

<?php foreach ($ds_name as $dsname): ?>
    $('#edit<?= $dsname->id ?>').click(function () {
        var text = $('.text-infoo<?= $dsname->id ?>').text();
        var input = $('<input id="attribute<?= $dsname->id ?>" type="text" data-id="<?php echo $ds_content->id; ?>"value="' + text + '" />');
        $('.text-infoo<?= $dsname->id ?>').text('').append(input);
        input.select();

        input.blur(function () {
            var text = $('#attribute<?= $dsname->id ?>').val();
            $('#attribute<?= $dsname->id ?>').parent().text(text);
            $('#attribute<?= $dsname->id ?>').remove();
        });
        $('#edit<?= $dsname->id ?>').hide();
        $('#ok<?= $dsname->id ?>').show();
    });
<?php endforeach; ?>

【问题讨论】:

    标签: php mysql ajax codeigniter


    【解决方案1】:

    你可以这样做

    $.ajax({
                url: "data.php",//file wich has query select to db table
                data: {id:theid},//describe your data here
                dataType: 'json',// type of data that will you get (JSON/HTML).
                type: 'POST',//sending type (POST/GET)
                success: function(data) {
                   //do change the select option
                }
            });
    

    祝你好运!

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2013-04-30
      • 1970-01-01
      • 2015-08-07
      • 1970-01-01
      • 2012-07-23
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多