I am using jeditable plugin to update some values in my textarea inline. When I update them the values are processed in a file save.php
and the value is stored in a table record in the database and the field is updated.
However my problem is once I have already updated the record and when I load or refresh the page, I cannot see the updated value in the field, the default click to edit is displayed until I click and edit the value in which case it displays the new value. I have read on other posts that the save.php should echo out the value to be displayed in the field.
My save.php code
<?php
if(isset($_POST['suck'])){
mysql_connect('localhost','root','');
mysql_select_db('inline_database');
$data = $_POST['suck'];
$result = mysql_query("INSERT INTO `form_data` VALUES('','$data')");
$id = mysql_insert_id();
$query = "SELECT * FROM `form_data` WHERE `id` = '$id'";
$retrieve_result = mysql_query($query);
while($row = mysql_fetch_assoc($retrieve_result)){
$get_id = $row['id'];
}
echo $get_id;
}
?>
My function code which is inside the index.html
$(".editable_textarea").editable("http://localhost/newedit/save.php", {
indicator : "<img src='img/indicator.gif'>",
loadurl : "http://localhost/newedit/save.php",
type : 'textarea',
submitdata: { _method: "post" },
//id : 'elementid',
//name : 'newvalue',
select : true,
submit : 'OK',
cancel : 'cancel',
cssclass : "editable",
tooltip : "Click to edit ",
});
My jeditable.js file
var blue =
$.fn.editable.defaults = {
name : 'suck',
id : 'id',
type : 'text',
width : 'auto',
height : 'auto',
event : 'click.editable',
onblur : 'cancel',
loadtype : 'GET',
loadtext : 'Loading...',
placeholder: 'click to edit',
loaddata : {},
submitdata : {},
ajaxoptions: {}
};
The Jeditable plugin documentation is here.
And this is the live Demo.