James Holland
James Holland

Reputation: 161

JQUERY getJSON / ajax response not being processed

I am sending a json request to a server as below:

$.getJSON("prod_search.php?type=getCustInfo&custID="+custID, function(json) {
  alert(json.address);
  $("#invAddress").html(json.address);
  $("#currency").html(json.second);
});

Using firebug to check, the response is below, but the alert shows 'undefined' and no values are inserted.

[{"address":"abc123","second":"ABC"}]

Any ideas?

Upvotes: 0

Views: 387

Answers (1)

Dr.Molle
Dr.Molle

Reputation: 117334

Use

json=json[0]

at first in the callback. You receive an array, and the object you like to access is the first(and only) item inside this array.

Upvotes: 2

Related Questions