I am using the jQuery Validator plugin with ASMX Web services. I would like not to have to use HTTP GET (for security reasons). I can successfully use POST when directly using $.ajax, but when it comes to the Validator plugin, I'm having a difficult time setting the remote.data property in the rules for a specific field that is remotely validated.
Out of the box the remote validation in the jQuery Validator plugin uses GET, which permits setting the $.ajax.data property to an object. This means I can assign each data object property to an anonymous function that returns the latest values entered or selected by the user. For example, for my phoneNumber field I can set: data: { countryId: function() { return $uxCountries.val(); }, selectedCarrierId: function() { return $uxCarriers.val(); } }, But for POST to work, among other changes the $.ajax.data property must be a string formatted as json. I cannot figure out a way to update this string after the Validator object initializes ($form.validate()) on page load. If I try to use an anonymous function to return a string, $.ajax seems to just do a .toString() operation on the function, returning JavaScript object type info. Can anyone suggest a good way to set the remote.data property for POST operations? It would be really nice if I could do something like data: $.format("{'phoneNumber':'{0}', 'countryId':'{1}', 'selectedCarrierId':'{2}'}", $phoneNumber.val(), $countries.val(), $selectedCarrierId.val()), and the validator would always use the latest values, not the values at the time when the validator is initialized.