开发者

JQUERY getJSON / ajax response not being processed

开发者 https://www.devze.com 2023-01-19 05:00 出处:网络
I am sending a json request to a server as below: $.getJSON(\"prod_search.php?type=getCustInfo&custID=\"+custID, function(json) {

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 fire开发者_如何学Gobug to check, the response is below, but the alert shows 'undefined' and no values are inserted.

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

Any ideas?


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消