views:

36

answers:

1

In a jquery ajax call I get sent back some JSON from the server and want to use some of it in the success callback. I pass in the data, but how do I get at a specific value (say "id")?

I tried this but I get undefined:

                      success   : function(data) {
                                    alert(data["id"]);
                                  },
+1  A: 

Your ajax request should look something like this:

$.ajax({
  url: "...",
  dataType: "json", 
  success: fuction(data){
    alert(data.id);
  });
zipcodeman