I am new to JSON format so please forgive my lack of knowledge. But somehow, I need to add some line breaks to my json_encode array so that it will parse with multiple lines. I've searched and searched but nothing fits my situation.
It's outputted as:
Following formats accepted: www.website.com website.com website.net/something
But I'm looking to output the data like this:
Website needs to be in the following formats:
www.website.com
website.com
website.net/something
I've tried:
echo json_encode(
array( 'status' => 'failed',
'message' => Website needs to be in the following formats:n
www.website.comn
website.comn
website.net/something
), JSON_PRETTY_PRINT);
But Javascript is parsing it as a literal string so the newlines are ignored and outputted. Can I send the data from PHP to javascript using straight JSON format or do I have to use an array?
I've also tried using <br />
.
EDIT :
I am outputting the following way:
$.ajax({
url: /forms/content_process.php,
type:'POST',
data: $(.content_cat).serialize(),
processData: false,
dataType: json,
success: function(response) {
if (response.status == failed) {
$(.content_status).css( background-color, red );
$(.content_status).text(response.message).slideDown(normal);
} else {
$(.content_status).css( background-color, green );
$(.content_status).text(Your category was submitted!).slideDown(normal);
}
}
});