I am retrieving a html code from my website and I need to store it into a database. Code to retrieve looks like this:
document.getElementById("content-link2").onmousedown = function() {mousedown()};
document.getElementById("content-link2").onmouseup = function() {mouseup()};
function mousedown() {
   var code2 = document.getElementById("content-link2").innerHTML;
    console.log(code2);
}
function mouseup() {
   var code2 = document.getElementById("content-link2").innerHTML;
    console.log(code2);
}
And output is:
    <title>Template 1</title>
        <link href="http://localhost/fyproject/public/templates/css.css" rel="stylesheet" type="text/css">
    <div class="logo">
        <img class="images" id="image" src="#" alt="Your Logo">
    </div>
<div contenteditable="true" id="content" class="draggable ui-widget-content refresh ui-draggable ui-draggable-handle" style="position: relative;"><p>hlo</p></div>
<div id="comments">
<form name="forma">
<textarea name="commentUser" id="commentUser" class="refresh" cols="40" rows="5">Comments here...
</textarea><br>
<input type="submit" value="Ready!" id="send-data"><!--onClick="writeComment(e);"--> 
<div id="editTxt" class="refresh" contenteditable="true">
<p>This text can be by the user.</p>
</div>
</form></div>
I have started to do AJAX code which is saved in js file and it looks like:
 function updateDatabase(newCode)
            {
            // make an ajax request to a PHP file
            // on our site that will update the database
            // pass in our lat/lng as parameters
            $.post('http://localhost/fyproject/public/template2', {
                 _token: $('meta[name=csrf-token]').attr('content'),
                 newCode: code2,
             }
            )
            .done(function(data) {
                alert(data);
            })
            .fail(function() {
                alert( "error" );
            });
        }
Route:
Route::post('template2', 'BuilderController@postDB');
Controller:
     public function postDB(Request $request) {
        $newLat = $request->input('newCode');
        return "Is This Really Working? Oh by the way: newLat: $newLat";
    }
However I get this error in a console:
POST http://localhost/fyproject/public/template2 500 (Internal Server Error)
Am I getting at the right track? What am I doing wrong here? If this is not good could I get a suggestion how to do this in another way?
Thank You
