Hello,
I have 2 textboxes on a main page, that has an action to a partial page called validate. The controller for that partial page does a sql query.
The main page has a button, called Save, and I tried adding the following:
On click:
Action 1. ajax call to the partial page
Action 2. check field value, if field value = 'Y', then follow through with the form submission, if field value = 'N', then don't do anything.
This validation is not working. Is there a better way to do this?
I have 2 textboxes on a main page, that has an action to a partial page called validate. The controller for that partial page does a sql query.
The main page has a button, called Save, and I tried adding the following:
On click:
Action 1. ajax call to the partial page
Action 2. check field value, if field value = 'Y', then follow through with the form submission, if field value = 'N', then don't do anything.
This validation is not working. Is there a better way to do this?
RE: Validations from a partial page
From your description I assume that the ajax submission call is doing some validation on the server, and the returned partial page contains a field with the results of this validation.
It is then this field that you are trying to check with the second action to determine whether to do the form submit.
If these assumptions are correct then the issue you have is that the ajax call is an asynchronous process. The processing wont wait for the response to be received, and instead will continue with the second action straight away. This will then fail because the field being checked doesn+?+?+?t yet exist.
The easiest way to resolve this would be to just move your second action to be an onload event on the partial page instead. This would mean it wouldn+?+?+?t try and check for the results of the server validation until it has completed.
I hope this helps.
Regards,
Gerard