1

I have found this link where shows me that \n works for my goal.

But it is not working in the way I am doing it.

$.ajax({
        url:'ajax/core/Ajax_Request.php',
        type:'POST',
        dataType:'json',
        success:function (result) {
            alert(result.error);
            }
});

In the php file I have

$resultado['error']='1\n2\\n3.';
echo json_encode($resultado);

And it is not showing a break line neither with \n or \\n

It is showing 1\n2\n3

Thanks for your time.

Community
  • 1
  • 1
kilkadg
  • 2,157
  • 4
  • 16
  • 21
  • possible duplicate of [Difference between single quote and double quote string in php](http://stackoverflow.com/questions/3446216/difference-between-single-quote-and-double-quote-string-in-php) and many others – kapa Feb 26 '13 at 14:46

1 Answers1

2

you need doble quotes on php side:

$resultado['error']= "1\n2\n3";
echo json_encode($resultado);
Saic Siquot
  • 6,513
  • 5
  • 34
  • 56