-1
Kann jemand mir helfen, eine AJAX-Anfrage für diese Art von Situation zu erstellen? Ich möchte, wenn ich auf die OK-ID klicke. Ich möchte nur den Inhalt aktualisieren und in der Datenbank gespeichert werden. Ich hoffe, dass mir hier jemand hilft. Danke.AJAX POST REQUEST mit jquery
VIEW FILE:
<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; ?>