Php 使用jquery的AJAX POST请求
有人能帮我为这种情况创建一个ajax请求吗?我想如果我点击ok id,我只想更新它的内容并存储在数据库中。希望这里的任何人都能在这方面帮助我。多谢各位 查看文件:Php 使用jquery的AJAX POST请求,php,mysql,ajax,codeigniter,Php,Mysql,Ajax,Codeigniter,有人能帮我为这种情况创建一个ajax请求吗?我想如果我点击ok id,我只想更新它的内容并存储在数据库中。希望这里的任何人都能在这方面帮助我。多谢各位 查看文件: <tbody> <?php foreach ($ds_name as $dsname): ?> <tr> <td><div class="text-infoo<?= $dsname->id ?>"><?= $dsname
<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; ?>
你可以这样做
$.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
}
});
祝你好运