Reading on response and such but what is a JSON view?

 

I am building an site which is 99% based on JSON responses and that gets
pushed back to the js based on the result / success / fail and the data sent
from the controller to the js updates the current view accordingly. 

Not using any new views or anything after submit  /view / add just the
standard html views / elements so I am wondering what is a JSON view? 

 

For example I try to submit a form sent via ajax:

 

In error the response from the server sent to the js from the controller is
like this::

 

{

"status":false,

                    "errors":{

                                        "title":["Please enter a title."],

                                        "from":["Please enter the from
who."],

                                        "description":["Please enter a
description."]},

                    "clear":false,

 
"token":"$2a$10$.3FRu2riTDzyXS3vXj5.LOVW3insbLfCyjpSfCadLEIOnuwu6uh02",

                    "message":{

                                         "title":"Not quite there!",

                                        "text":"Please correct the following
errors and try again."}

}

 

 

JS SNIP:

.done(function(r){

                if (r.status === true) {

                                alertMessage('success', r.message);

                                errorUpdate(handler);

                } else {

                                if(r.illegal){

                                                securityError(r);

                                }

                                alertMessage('error', r.message, r.errors);

                                setErrors(r.errors, sel);  

                }              

})

 

So the js will update the form automatically (by-passing the cake error
notifications , added dynamically) adding the errors where they are, reset
the CSRF token and the general fail message. No view is used / rendered so
just wondering if I am doing this wrong?

 

And what would a JSON view look like anyways?

 

As always thanks in advance.

 

Dave Maharaj

Freelance Designer | Developer
Description: header_logo
www.movepixels.com  |   <mailto:[email protected]> [email protected]  |
709.800.0852

 

-- 
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

--- 
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/groups/opt_out.

<<image001.jpg>>

Reply via email to