리자

json 사용시 엔터(newline) 넘길때 에러나는 경우

· 2009-11-13 (금) 16:31:18 · 9250 · 2
function parse($text) { 
   
// Damn pesky carriage returns... 
    $text
= str_replace("\r\n", "\n", $text); 
    $text
= str_replace("\r", "\n", $text); 
 
   
// JSON requires new line characters be escaped 
    $text
= str_replace("\n", "\\n", $text); 
   
return $text; 
} 
[이 게시물은 관리자님에 의해 2011-10-31 16:55:28 jQuery에서 이동 됨]
|

댓글 2개

2009-11-20 (금) 17:56:24
저 같은경우에는 \n을 아예 사용금지. 무조건적인 테그로 구현했습니다 ㅠㅠ
2010-04-08 (목) 10:09:52
제가 쓰는 폼값정리 방법입니다.
asp 는 한글이 잘 안넘어가서 변환이 많네요^^


// 폼값을 정리한다.
var strData = $("form[name=frm]").serialize().replace(/=(.[^&]*)/g,function($0,$1){ return "="+escape(decodeURIComponent($1).replace(/\n/g,"\r\n"))}).replace(/%26/g, "&").replace(/%3D/g, "=");
댓글을 작성하시려면 로그인이 필요합니다.

개발자팁

5,403건

개발과 관련된 유용한 정보를 공유하세요. 질문은 QA에서 해주시기 바랍니다.

+
분류 제목 글쓴이 날짜 조회
기타 09-02-13 조회 3,321
PHP 09-02-09 조회 4,076
PHP 09-02-09 조회 4,619
JavaScript 09-02-09 조회 3,667
기타 09-02-09 조회 3,508
MySQL 09-02-09 조회 2,997
JavaScript 09-02-03 조회 7,063
jQuery 09-01-30 조회 2,629
jQuery 09-01-25 조회 3,723
jQuery 09-01-24 조회 3,997
jQuery 09-01-23 조회 4,360
jQuery 09-01-20 조회 6,276
jQuery 09-01-20 조회 4,645
기타 09-01-17 조회 3,088
기타 09-01-15 조회 2,435
jQuery 09-01-14 조회 5,941
jQuery 09-01-10 조회 3,265
jQuery 09-01-09 조회 3,161
기타 09-01-08 조회 3,474
jQuery 09-01-06 조회 2,757
jQuery 09-01-05 조회 7,390
MySQL 08-12-30 조회 3,491
기타 08-12-30 조회 4,826
jQuery 08-12-29 조회 4,760
기타 08-12-27 조회 2,232
JavaScript 08-12-27 조회 2,976
기타 08-12-27 조회 3,030
기타 08-12-27 조회 3,914
jQuery 08-12-20 조회 4,650
JavaScript 08-12-20 조회 5,309