Live Brilliant

ajax json 엔터값 로드 문제 본문

개발은 핵찜이야/AJAX

ajax json 엔터값 로드 문제

주인정 2012. 12. 17. 10:53

ajax 로드시 내용에 엔터부분 로드 안되는 에러 발생


$.ajax({

url:'',

type:'post',

data:,

dataType:'json',

success:function(jsonData)

{
content: "이벤트 진행
           대박 할인"
}

});


[해결] 

1.디비에서 불러온값을 <BR>로 치환해서 보내고

$text_content = str_replace("\r\n", "<BR>", $row[content]); 



ajax jsonData 데이터 받는곳에서 <BR>을 다시 \r\n로 치환하면 된다.


var text_content = jsonData.content.replace('<br>', '\r\n'); 

$("form[name=form] textarea[name=content]").val(text_content);

'개발은 핵찜이야 > AJAX' 카테고리의 다른 글

crossdomain jsonp 사용  (0) 2013.11.14
jquery ajax load more 더보기 기능  (0) 2013.01.03
ajax CDATA  (0) 2012.05.30
Comments