The beauty of json is that you can transfer alot of different data in
an organized way. You can very easily send back success/failure status
along with the html.
success: function(response) {
// Response was a success
if (response.status) {
//update my target div
$('#target_div').html(response.html);
// Response contains errors
} else {
// return the form with the errors
}
On Jan 10, 5:00 pm, "Dave Maharaj :: WidePixels.com"
<[email protected]> wrote:
> I need some help with a form.
>
> I submit the form fine, my problem is depending on the success or failure of
> the form being saved. I will try to explain as simple as possible
>
> form is in its own div <form here ..... >
>
> <div target> saved data will appear here</div>
>
> So what I need is i guess json success true or false response from the form
> being saved or not then in my success
>
> success: function(response) {
> // Response was a success
> if (response) {
> //update my target div
> // Response contains errors
> } else {
> // return the form with the errors
>
> }
>
> But if I am returning json I cant return my normal html after the successful
> save, and if I return my response as html there is no way to tell the js
> what to do.
> The form or the target is html code
>
> How can I tell what the response was (true or false) and return the
> appropriate html code for the appropriate form or target?
>
> Thanks
>
> Dave