반응형

[php]
<?

$que = "select name from tb";
$res = dbQuery($que);
$row = mysql_fetch_assoc($res);

$return['row'] = $row;

ob_start();
?>
<p>html '오케이' "okkks.tistory.com"</p>
<?
$return['html'] = ob_get_contents();

ob_end_clean();

$return['kor1'] = '오케이';
$return['kor2'] = urlencode('오케이');
$return['result'] = 'true';

echo json_encode($return);

?>

 


[javascript, jquery]
$.post(
          'php 파일 주소'
          ,전송할 값들
          ,function(data){
                    var json = $.parseJSON(data);
                    alert(json);
                    alert('row=' + json.row['name']);
                    alert('한글 1='+ json['kor1']);
                    alert('한글 2='+ decodeURI(json['kor2']));
                    alert('html=' + json['html']);
}); 



더보기>

- javascript, jquery json \n 처리

반응형
Posted by 은둔고수