From ca07e994a94d1369e73d97bbaeee6800cf0b4d7c Mon Sep 17 00:00:00 2001 From: sparky672 Date: Tue, 21 Apr 2015 11:03:36 -0500 Subject: [PATCH] Update remote-method.xml There is a lot of confusion surrounding proper usage of the `remote` method based on the number of Stack Overflow questions about it. I am proposing this slight change to help clarify. Proposed: The serverside response must be a JSON string that must be `"true"` for valid elements, and can be `"false"`, `undefined`, or `null` for invalid elements, using the default error message. If the serverside response is a string, eg. `"That name is already taken, try peter123 instead"`, this string will be displayed as a custom error message in place of the default. --- entries/remote-method.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/entries/remote-method.xml b/entries/remote-method.xml index 242fd4f..28bf566 100644 --- a/entries/remote-method.xml +++ b/entries/remote-method.xml @@ -3,7 +3,7 @@ remote method Requests a resource to check the element for validity. - The serverside resource is called via jQuery.ajax (XMLHttpRequest) and gets a key/value pair corresponding to the name of the validated element and its value as a GET parameter. 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. + The serverside resource is called via jQuery.ajax (XMLHttpRequest) and gets a key/value pair corresponding to the name of the validated element and its value as a GET parameter. The serverside response must be a JSON string that must be "true" for valid elements, and can be "false", undefined, or null for invalid elements, using the default error message. If the serverside response is a string, eg. "That name is already taken, try peter123 instead", this string will be displayed as a custom error message in place of the default.

For more examples, take a look the marketo demo and the milk demo.