나는 여러 div에서 데이터를 게시하는이 자바 스크립트가 있지만 나는 linebreaks 계속 유지할 수없는 것.줄 바꿈을 유지하지 Jquery 게시물
필자가 찾은 내용에 .text()를 사용한다는 사실과 관련이 있다고 생각합니다. 아마 줄 바꿈을 유지하지 않을 수도 있습니다. 나는 .html()로 시도했지만 어떤 이유로 든 div에 새 줄에 작성된 모든 텍스트를 div로 작성합니다.
코드는 다음과 같습니다 :
<script type="text/javascript">
$(document).ready(function() {
$("#actor_result").load('xml/actortoxml.php?owner=<?php echo $_SESSION['username'] . "&id=" . $_GET['id']; ?>');
$('#save_editable').click(function() {
var name = $(document).find('#actorname').text();
var current = $(document).find('#currenthealth').text();
var max = $(document).find('#maxhealth').text();
var effects = $(document).find('#actoreffects').text();
var notes = $(document).find('#actornotes').text();
$.ajax({
url: 'actor_profile.php',
type: 'POST',
data: {
update: 'true',
actorid: <?php echo $_GET['id']; ?>,
actorname: name, currenthealth: current, maxhealth: max, actoreffects: effects, actornotes: notes
},
success : function() {
// gets called when ajax request completes successfully
$("#actor_result").hide().load('xml/actortoxml.php?owner=<?php echo $_SESSION['username'] . "&id=" . $_GET['id']; ?>').fadeIn(500);
},
error : function(err) {
// in case of error
console.log(err);
alert('error');
}
});
});
});
</script>
편집, 이것은 xml 파일에서 HTML 생성됩니다
<div id="actor_result" style="display: block;">
<!--?xml version="1.0"?-->
<div class="row-fluid row span6 offset3">
<div class="media well well-small">
<a class="pull-left" href="#"><img class=
"media-object img-circle circle128" src=
"images/avatar/actor/Davius.png"></a>
<div class="media-body page-header actor-profile">
<div class="editable_name" contenteditable="true" id=
"actorname">
<h4 class="media-heading">Davius</h4>
</div><small><strong>awarnhag's minion</strong></small>
</div><strong>Health:</strong>
<div class="div_inline editable_hp" contenteditable="true" id=
"currenthealth">
17
</div>/
<div class="div_inline editable_hp" contenteditable="true" id=
"maxhealth">
20
</div>hp
</div>
<h5><span class="label">Effects</span></h5>
<div class="editable well well-small" contenteditable="true" id=
"actoreffects">
Mumblecore bushwick sed, nulla street art dolore delectus wolf
american apparel artisan sriracha. Laboris seitan hoodie,
freegan brooklyn letterpress adipisicing chambray mixtape id
tofu organic butcher small batch. Art party carles readymade
messenger bag williamsburg. Irony placeat sustainable, high
life cillum yr sed vinyl pork belly messenger bag williamsburg
VHS. Occaecat lo-fi readymade gluten-free 3 wolf moon. Ad tofu
twee, blog nulla mumblecore gentrify brooklyn odio cliche
selvage put a bird on it pork belly chillwave deserunt. Ea
assumenda chillwave, keytar velit tumblr pour-over enim VHS
mcsweeney's blog.aaaa
</div>
<h5><span class="label">Notes</span></h5>
<div class="editable well well-small" contenteditable="true" id=
"actornotes"></div>
</div>
</div>
어리석은 생각을하지만, 어쩌면 시도 CSS :'* {공백 : 사전}'http://stackoverflow.com/a/656648/483371 – andytuba
당 당신은 XML을 게시 할 수 있습니까? – trebuchet
xml은 xsl에 의해 html로 변환됩니다. – Marty