Welcome Guest, Not a member yet? Register   Sign In
Trying to not go to a different page after form submit...
#2

For this I would recommend submitting the form with Javascript VIA ajax (jQuery is a nice javascript lib for this) against a different controller method. That controller method can then return JSON which you can test in your Javascript for a error or link or something. Which you can then display in your <div> for example. (Thank you here is your link etc...)

I have been using this method for years to post all of my forms to have the model validation done by the model only returning the responds to the end user. If it's all good then the form is submitted "for real". Of course the controller I runs it again against the same model (just for security because it already was checked it "should" be good). That keeps me from writing form validation in Javascript AND again in PHP. I only need to write it once in PHP (in the model). This also saves me from the form post -> validate -> fail -> form redisplay -> form post -> validate -> fail.... loop. The user never posts the form until it's actually "good".

Hope that helps?
Reply


Messages In This Thread
RE: Trying to not go to a different page after form submit... - by dmyers - 01-14-2015, 06:23 AM



Theme © iAndrew 2016 - Forum software by © MyBB