Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/237.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何转义html标记?在phonegap android中从php检索的json中_Php_Android_Ajax_Json - Fatal编程技术网

如何转义html标记?在phonegap android中从php检索的json中

如何转义html标记?在phonegap android中从php检索的json中,php,android,ajax,json,Php,Android,Ajax,Json,我正在创建一个应用程序,其中我在服务器端使用php。当进行Ajax调用时,它会调用php从表中检索数据,但问题是某些表包含html和特殊字符标记,因此我在Ajax中遇到一个错误: 05-31 00:59:07.670: D/CordovaLog(872): Server is not responding... Please try again: SyntaxError: Unexpected token < 05-31 00:59:07.670: I/chromium(872): [IN

我正在创建一个应用程序,其中我在服务器端使用php。当进行Ajax调用时,它会调用php从表中检索数据,但问题是某些表包含html和特殊字符标记,因此我在Ajax中遇到一个错误:

05-31 00:59:07.670: D/CordovaLog(872): Server is not responding... Please try again: SyntaxError: Unexpected token <
05-31 00:59:07.670: I/chromium(872): [INFO:CONSOLE(342)] "Server is not responding... Please try again: SyntaxError: Unexpected token <", source: file:///android_asset/www/home.html (342)
05-31 00:59:07.670:D/CordovaLog(872):服务器没有响应。。。请重试:语法错误:意外标记<

05-31 00:59:07.670:I/chromium(872):[INFO:CONSOLE(342)]“服务器没有响应…请重试:SyntaxError:Unexpected token您可以使用
escapeHtml
返回给定纯文本的HTML转义表示。 有关更多信息,请参阅

或者您可以使用
TextUtils.htmlEncode(“您的json标记”)
对html进行编码

编辑
由于您使用的是phonegap,因此您可以将
htmlencoding
isPHP也用作

htmlentities($str, ENT_QUOTES);
有关更多信息,请参阅

要在php中编码html并在应用程序中解码,您可以参考此链接

您能给我举个例子吗?您提供的页面链接是为phonegap中的本机im开发应用程序而提供的。@neeravsha要用php编码html,请参见编辑的答案。但是如果我们用php编码json数据,如何在phonegap中的html页面中解码它。