Hi all,
Using PHP, and MySql, I am trying to implement this rather snazzy in-place editor available here:
tutorial: http://www.davehauenstein.com/code/jquery-edit-in-place/
js file: http://davehauenstein.com/code/scripts/jquery.inplace.min.js
OK what is happening is,
- I click the element to edit the text.
- I clear the old text, and enter the new text.
- I click outside of the element to initiate Ajax to save the new text.
- Ajax shows "Saving..", which is default text for updating element.
- The new text is updated in the database.
- Element reloads, and instead of showing the new text inside of element, the element shows (Click here to edit text), which is the default text in the js file for an element that returns empty.
The Problem: Only once I refresh the page manually, is the new text loaded in element. Instead of loading in the element without refreshing.
The element with in-place edit:
<div class="editme1"><?php
$content = $_GET['update_value'];
// i added this to try and get the updated value but im
// not really sure, just a guess. i have also used $_POST
// in an attempt to catch it....but i feel stupid even
// saying that..lol
if(!empty($content)) { echo "$content"; } else
{ echo "$row[profilevalue_8]"; }
?></div>
The file (update.php) which updates the database:
<?php include('includes/config.php');
include('includes/functions.php');
$name = $_POST[update_value];
$update = mysql_query("UPDATE profilevalues SET profilevalue_8 = '".$name."'
WHERE profilevalue_user_id = '".uid()."'") or die(mysql_error());
?>
The javascript
<script type="text/javascript">
$(document).ready(function(){
$(".editme1").editInPlace({
url: "http://www.mysite.com/update.php",
params: "ajax=yes",
});
</script>
The issue is I guess, is that I cant seem to reflect the changes in the element as expected.
I would be so grateful for any help.
Thanks