jzaefferer/jquery-validation — Issue #237: Remote validation data as function
Author: marcos-fedato
Created: 2011-10-20 22:51:39+00:00
State: open

The jQuery ajax does not accept functions as data, it makes sence $.ajax is creared and used at the same time.

The remote validation calls is set once and called a few times.

I use a remote validation for multiple keys on the database so i serialize the all form and passes is on the data param.

But it does not work since if i put the data: $('form:first').serializeArray() it gets only the initial value of the form.

If i put data: function () {$('form:first').serializeArray();} it does nothhing cause $.ajax doesn`t accept functions as data.

i was thinking inchange the remote: function to check the params and parce the param.data if it is a function

if (jQuery.isFunction(param.data))
{
param.data = param.data();
}

But i don`t know if it will change the original param, becouse it must retain the function for next calls

more on:

http://forum.jquery.com/topic/function-as-parameter-data-in-ajax-requests