CKEditor can someone help me please?

In a project I try to implement the ckeditor

In my form I have:

    <label>Pagina titel</label>
    <input name="pagina_titel" type="text" class="textfield" id="pagina_titel" value="<?php echo $pagina_content['pagina_titel']; ?>" tabindex="1" required>
    <label for="pagina_content">Pagina content</label>
    <textarea name="pagina_content" id="pagina_content"></textarea> 

I have included ckeditor in the head of the document:

<script type="text/javascript" src="/../js/ckeditor/ckeditor.js"></script>

After that i replaced the texarea and made the ajax request:

CKEDITOR.replace( 'pagina_content' );

$("#wijzig_content_form").on("submit", function(e) {
    var pagina_naam    = $("#pagina_naam").val(),
        pagina_titel   = $("#pagina_titel").val(),
        pagina_content = CKEDITOR.instances.pagina_content.getData(),
        dataString     = 'pagina_titel =' + pagina_titel + '&pagina_content =' + pagina_content;
        url : "/admin/pagina/update_pagina_content",
        type: "post", 
        data: dataString,
        success: function(response) {
            $("#bericht").dialog( "option", "buttons", [{
                 text: "Close",
                 click: function() {
                     window.location = '/admin/pagina/pagina_content/'+pagina_naam;

But nothing is happening. The page is just opening again. No dialog appers, the insert is not happening, nothing. Does someone see what I am doing wrong?

Thank you in advance

1 Like

This remains a complete mystery Chrome dev tools gives me the right form values:

pagina_naam :home
pagina_titel :Welkom
pagina_content :<p>Test</p>

Running a query in phpMyAdming with these values

UPDATE pagina_content
   SET pagina_titel = 'Welkom'
     , pagina_content = '<p>Test</p>'
 WHERE pagina_naam = 'home';

doesn’t give me any errors. Which leaves me with the Controller where I have the following:

    public function update_pagina_contentAction()
        $pagina_titel     = filter_input(INPUT_POST, 'pagina_titel', FILTER_SANITIZE_STRING);
        $pagina_content = filter_input(INPUT_POST, 'pagina_content', FILTER_UNSAFE_RAW);
        $pagina_naam    = filter_input(INPUT_POST, 'pagina_naam', FILTER_SANITIZE_STRING);
        $update         = $this->page->update_pagina_content($pagina_titel,$pagina_content,$pagina_naam);
        $content_succes = new View('/admin/pagina_content_succes.php', compact('pagina_naam'));
        echo $content_succes->render();        

I have realy know idea why the update isn’t happening.

Where and how can I check what is the reason for this failure. Thank you in advance

Ok I am a step nearer to a sollution I think. I left the dialog out of the Ajax call and guess what happened. When I submitted the form the first time nothing happend, when however I submitted it the second time the changes in the database took place. What can be the reason for that to happen?

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.