Can be wrong response. For example, cake debug info in it.

On Oct 24, 11:01 am, hahmadi82 <[email protected]> wrote:
> Hi, so I noticed that if I change the type from "json" to "JSON" it prints
> the alert. However, if I try to print data.result in the alert, the alert
> prints "undefined". If I print data, the alert responds with
> "{"result":"SHOE"}". This is weird... why is the JSON not working properly?
>
>
>
>
>
> Dr. Loboto wrote:
>
> > This callback is executed only on success. Maybe it is not success?
>
> > On Oct 24, 3:22 am, hahmadi82 <[email protected]> wrote:
> >> any help please?
>
> >> hahmadi82 wrote:
>
> >> > I'm trying to write a simple JSON post and the callback alert does not
> >> > show up no matter what I do.  I used firebugs to see if the post was
> >> > getting any response and "SHOE" returns.  So why is the alert not
> >> working
> >> > in the callback?
>
> >> > view code:
> >> >            $('#GaragePartAddfrompartlistForm').click(function() {
> >> >            var item = "CHEESE";
> >> >                    $.post("garage_parts/getlastid", { 'item' : item },
> >> >                              function(data){
> >> >                                alert(data.result);
> >> >                              }, "json");
> >> >         });
>
> >> > controller code:
> >> > function getlastid() {
> >> >            $newid = "SHOE";
> >> >         $array = array('result' => $newid);
> >> >         echo json_encode($array);
> >> >     }
>
> >> --
> >> View this message in
> >> context:http://www.nabble.com/Jquery-JSON-Ajax-Callback-Not-Working-tp2596699...
> >> Sent from the CakePHP mailing list archive at Nabble.com.
>
> --
> View this message in 
> context:http://www.nabble.com/Jquery-JSON-Ajax-Callback-Not-Working-tp2596699...
> Sent from the CakePHP mailing list archive at Nabble.com.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to