简体   繁体   English

如何在ajax responsetext中添加换行符

[英]How to add new line character in ajax responsetext

How to add a new line character in ajax responsetext. 如何在ajax responsetext中添加换行符。 I have to return the Exception message containing error code and description which I have to then show using Javascript alert box. 我必须返回包含错误代码和描述的异常消息,然后必须使用Javascript警报框显示该消息。

PHP code snippet returning an error exception: PHP代码段返回错误异常:

echo('Update Aborted\r\n'.$mIAPException->getErrorCode() . ': ' . $mIAPException->getFurtherDetails());

Javascript code snippet: JavaScript代码段:

alert(client.responseText);

This is not working. 这是行不通的。

You need to use " -quoted strings. In ' -quoted strings, the \\r and \\n chars are nothing special. 您需要使用"引号的字符串。在'引号的字符串中, \\r\\n字符没有什么特别的。

echo "\n"; // spits out a newline
echo '\n'; // spits out a '\' char and an 'n' char

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM