Working on a username availability function. For an existing user changing their username I want to pass the new username and the ID of the person to a remote function. This function works fine on the backend (if the ID is included it looks for the username excluding the ID).
Add the ID (hidden form field with ID = sid) throws a stack overflow error "maximum call stack size exceeded". What's the proper way to pass both the user's ID and the proposed new username?
new_username: {
remote: {
url: [url to function],
type: 'post',
data: {'sid':sid, 'new_username':new_username},
dataFilter: function(data, type){
return type == 'json' ? data.replace(/^(\/{2})?/, '') : data;
}
}
}
The HTML form looks like this:
<form class="stdForm" id="jqv" name="stForm" action="" method="post">
<input type="hidden" name="sid" id="sid" value="12345"/>
<div>
<label for="new_username">Login Username</label>
<input type="text" name="new_username" id="new_username" value="[current username]" />
</div>
<div>
<input type="submit" value="Update"/>
</div>
</form>
The full javascript is a long jquery validation script. The fields "new_username" and "sid" are not referenced anywhere else in the form. When I just send the username (without the ID) I have a separate rule set that works:
username_check: {
remote: {
url: [url to function],
type: 'post',
dataFilter: function(data, type){
return type == 'json' ? data.replace(/^(\/{2})?/, '') : data;
}
}
}
Where username_check is the ID of the field in the form.
sidandnew_username?returnthe value. Just follow the second example in the docs.