Haring10
Haring10

Reputation: 1557

get content from div for form input laravel

I have a form in laravel (not using blade) using CKEditor. I am trying to get the content from it in a div called editorcontents when I submit the form as it is submitting a blog post (so it needs to have the formatting from that div as well).

I tried assigning a name to the div, but no luck. How can I use the div just as a input field?

<div id="editorcontents" name="editorcontents">
</div>

$content = Input::get('editorcontents');
return $content;

Upvotes: 3

Views: 3294

Answers (1)

HoangHieu
HoangHieu

Reputation: 2840

Try this with ajax in jQuery to get html content of editorcontents and post this to controller in server :) ... I hope this help

Html

<div id="editorcontents" name="editorcontents">
</div>

Jquery

    var inputValue = $("#editorcontents").html;     
    $.ajax( {
        type : "POST",
        cache : false,
        async : true,
        global : false,
        url : "URL POST DATA",
        data : {
            editorcontents : escape(inputValue),
        }
    } ).done( function ( data )
    {   
        //Handle event send done;
    } )

Upvotes: 1

Related Questions