Little problem using jEditable: I use jEditable on a paragraph and my
PHP file successfully updates the database upon submission. But after
I click the OK button or press enter when I 'jEdit' such a paragraph,
the content of the paragraph always changes to 'Click to edit', no
matter what I entered in the input area. After I reloaded the page I
can see that the database was succesfully updated: the paragraph shows
the updated text.

Here's some code:

The main file:
<script type="text/javascript" src="jQuery.js"></script>
<script type="text/javascript" src="jEditable.js"></script>
<script type="text/javascript">
    $(document).ready(function() {
        $('.poster').editable('editajax.php', {
            name : 'pCont',
            id : 'idee',
            submit : 'OK',
            cancel : 'Cancel'
        });
    });
</script>

Also in the main file:
<?php
    require_once 'includes/connection.php';
    $query = "Select * from site_content WHERE page = 1";
    $result = mysql_query($query);
    while ($post = mysql_fetch_array($result)) {
        echo "<h1>" . $post['Post_Title'] . "</h1><br/>";
        echo "<p class='poster' id='" . $post['ID'] . "'>" . $post
['Post_Content'] . "</p>";
    }
?>


editajax.php:
<?php
    include 'includes/connection.php';
    $pCont = $_REQUEST['pCont'];
    $id = $_REQUEST['idee'];
    $updateq = "UPDATE site_content SET Post_Content = '$pCont' WHERE
ID ='$id'";
    mysql_query($updateq);
     $rett = "<p>".$pCont."</p>";
    return $rett;
?>

On that last thing: I also tried returning $pCont without the
paragraph tags, doesn't make any difference.

So a short summary of my situation: jEditable works as it should,
except for one thing: after I click OK and submit the form, it does
not display the updated text on the page but 'Click to edit' is all it
says.

Could anybody help me?

Thank you very much in advance.

Kind regards,

Reply via email to