Not only that, but with JSON, you need to eval the results, so your example
would be

$ .get( "cfc/scalehouse.cfc?method=validateTruckCode&truck_code=" + $(
"input") .val (),

function (response){

                 $('#content').html(response);  //THIS OUTPUTS
{"TRUCK":"INVALID","ISVALID":false}

response = eval("("+response+")");

alert (response.TRUCK);         //Should alert INVALID



        });


On 2/6/07, Tim Gossett <[EMAIL PROTECTED]> wrote:

On 2/6/07, Paul <[EMAIL PROTECTED]<https://mail.google.com/mail?view=cm&tf=0&[EMAIL 
PROTECTED]>>
wrote:

>  I'm sure this is something simple but I'm going nuts.  I'm simply
> trying to access JSON data that is being returned by an ajax call.  This is
> my first attempt to play with JSON, so here we go…
>
>
>
> $ .get( "cfc/scalehouse.cfc?method=validateTruckCode&truck_code=" + $(
> "input") .val (),
>
> function (response){
>
>                   $('#content').html(response);  //THIS OUTPUTS
> {"TRUCK":"INVALID","ISVALID":false}
>
> alert (response. TRUCK);         //THIS ALERTS "undefined"—shouldn't it
> alert "INVALID"?
>
>
>
>          });
>
>
>
> Can you tell what I've done wrong?
>

In JSON, object attributes should not be in quotes. The response should
return this:

{
    TRUCK:    "INVALID",
    ISVALID:    false
}

_______________________________________________
jQuery mailing list
[email protected]<https://mail.google.com/mail?view=cm&tf=0&[EMAIL PROTECTED]>
http://jquery.com/discuss/


_______________________________________________
jQuery mailing list
[email protected]
http://jquery.com/discuss/

Reply via email to