PHP et Ajax
Posté : 09 juil. 2016, 22:45
Bonjour, je ne savais pas trop si c'était ici que je devais posté, mais bon essayons quand même
J'ai créer un script en ajax pour modifier une donnée dans la base de donnée, mais j'aimerais qu'il rafraichi le php aussi, mais comment dois-je faire ?
Voici le JavaScript:
Agent5acad27
J'ai créer un script en ajax pour modifier une donnée dans la base de donnée, mais j'aimerais qu'il rafraichi le php aussi, mais comment dois-je faire ?
Voici le JavaScript:
<script type="text/javascript">
$(document).ready(function()
{
$(".EditQTY").click(function()
{
var ID=$(this).attr('id');
$("#show_"+ID).hide();
$("#hide_"+ID).show();
}).change(function()
{
var ID=$(this).attr('id');
var show=$("#hide_"+ID).val();
var dataString = 'id='+ ID +'&qty='+show;
$("#status_"+ID).html('<img src="img/loading.gif" />');
if(show.length>0)
{
$.ajax({
type: "POST",
url: "inventory_qty_ajax.php",
data: dataString,
cache: false,
success: function(html)
{
$("#show_"+ID).html(show);
}
});
}
else
{
alert('Enter something.');
}
});
$(".editbox").mouseup(function()
{
return false
});
$(document).mouseup(function()
{
$(".editbox").hide();
$(".text").show();
});
});
</script>
Et voici la donnée à rafraichir:
<td id="status_<?php echo $id; ?>"><?php if ($status == 'ordered') { echo '<label <label id="result" class="label label-warning">Ordered</label>'; } elseif ($qty <= $qtyalert) { echo '<label <label id="result" class="label label-danger">To order</label>'; } elseif ($qty >= $qtyalert) { echo '<label <label id="result" class="label label-success">In stock</label>'; } ?></td>
Merci, Agent5acad27