Ciao a tutti sto usando la libreria quickedit di jQuery per permettere la modifica veloce di un singolo testo.
Ora non ho problemi nel modificare un testo scritto a mano, ma riscontro qualche problema quando il testo è preso da db e lo devo andare ad aggiornare .
Codice PHP:
header('Content-Type: text/javascript; charset=utf-8');
$value = $_POST['value'];
$body = trim($value);
$sqlQuery = "UPDATE Entita_24 SET Field234='".$body."' WHERE Field231='".$iId."' AND Field232='".$bando."' ";
$rs = mysql_query($sqlQuery) or die(mysql_error());
$sql = "SELECT Field234 Entita_24 WHERE Field231='".$iId."' AND Field232='".$bando."' ";
$rs = mysql_query($sqlQuery) or die(mysql_error());
while($row= mysql_fetch_array($rs)){$body = $row['Field234']; }
echo json_encode(array(
'status' => 'success',
'body' => $body
));
Codice jQuery
codice:
$('#demo1').quickEdit({
textarea: true,
$.ajax({
type: 'POST',
url: 'quickedit.php',
data: {value: "Text data which is sent to the server"},
// come posso impostare il data????
dataType: 'json',
success: function (obj) {
if (obj.status == 'success') {
if (obj.body) {
$t.html(body);
}
}
}
});
Grazie a tutti ...