我想硬编码三个键值对
[{code:"US",name:"United States"},{code:"CA",name:"Canada"}, {code:"MX",name:"Mexico"}]
等,并将响应作为数组列表发送
对象格式为[,]。
我在列表中进行迭代时访问了像country.code和country.name这样的值,但是到目前为止,我将国家作为对象发送,而我希望它作为一个列表,我想将国家作为对象。
以下是代码:
return $.ajax({
url: '/commonDataCal/commondata',
type: 'post',
dataType: 'json',
data: data,
locale: 'en_US',
success: function(data) {
if (data.CALError) {
var CountryListResponse = [ country ];
country = {code:"US", name:"United States"}, {code:"CA", name:"Canada"}, {code:"MX", name:"Mexico"};
success.call(this, CountryListResponse);
} else if (data.CountryListResponse.successful) {
data.CountryListResponse.countryList.splice(230,1);
data.CountryListResponse.countryList.splice(169,1);
success.call(this, data.CountryListResponse.countryList);
} else {
error.call(this, data.CountryListResponse);
}