javascript - Textarea linebreak using ajax -


i got textarea updating description when save using ajax doesn't follow spaces made in textarea.

$('#edit-desc').on('click', function () {     var = $('.edit-description'),      v = i.val();     if ($(this).hasclass('edit-desc')) {        $(this).text('update');        item_val = $('#desc_item').html().replace(/<br>/gi, '\n');        $('.edit-description').show();        $('.edit-description').val(item_val);        $('#desc_item').hide();        $('.edit-description').focus();        console.log("you pressed edit");     } else {        $(this).text('edit');        item_val = $('.edit-description').val().replace(/\n/g, '<br/>');        item_id = $('#collection_item_id').val();        $('.edit-description').hide();        $('#desc_item').show();        $('#desc_item').html(item_val);         $.post('php/edit-item-description.php', {item_id: item_id,        item_val: item_val}, function(e){            location.reload();        });     }     $(this).toggleclass('edit-desc'); }); 

and on edit-item-description php is

<?php     session_start();     include 'connect.php';     include 'exec/functions.php';      $edit['item_id'] = $_post['item_id'];     $edit['brand'] = nl2br($_post['item_val']);      if(editcollectionname($edit)){         echo "success";     }else{         echo "something wrong";     } ?> 

when typed: b c d in textarea, , save it. shows abcd instead of having spaces /
in it


Comments

Popular posts from this blog

Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.12:test (default-test) on project.Error occurred in starting fork -

windows - Debug iNetMgr.exe unhandle exception System.Management.Automation.CmdletInvocationException -

configurationsection - activeMq-5.13.3 setup configurations for wildfly 10.0.0 -