从jquery文档中,描述了jquery validate插件的远程功能:
The response is evaluated as JSON and must be true for valid elements, and can be any false, undefined or null for invalid elements, using the default message; or a string, eg. "That name is already taken, try peter123 instead" to display as the error message.
我可以确认您的服务器是否返回有效JSON(不仅仅是有效的JS),返回一个字符串是可能的。在 Ruby on Rails 中,我能够通过以下方式完成此任务"my string".to_json
,它负责任何必要的转义。不确定 PHP 方法是什么。 JSON 字符串需要双引号,如下所示:'My name is "Liam"'.to_json => ""My name is \\"Liam\\"""
。无论您的服务器平台是什么,您都需要提供类似于其右侧的字符串=>
.
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)