json 사용시 엔터(newline) 넘길때 에러나는 경우 > 개발자팁

개발자팁

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

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

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

본문

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에서 이동 됨]
추천
1
  • 복사

댓글 2개

제가 쓰는 폼값정리 방법입니다.
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, "=");
© SIRSOFT
현재 페이지 제일 처음으로