我有一系列城市和 ID,如下所示:
Brønderslev|810,Frederikshavn|813,Hjørring|860,Jammerbugt|849,Læsø|825,Mariagerfjord|846,Morsø|773,Rebild|840,Thisted|787,Vesthimmerland|820,Aalborg|851
我不想要这个:
<option value="810">Frederikshavn</option>
我确实想要这个:
<option value="813">Frederikshavn</option>
逗号分隔键/值对,管道分隔键和值。
我已经走了这么远,但它似乎没有循环?
//Get cities by Region
功能GetCitiesByRegion(参数){
var params = '{"regionGuid":"' + args + '"}'
var request = {
type: "POST",
async: false,
cache: false,
url: "http://" + location.hostname + "/webservices/services.svc/GetCitiesByRegion",
contentType: "application/json; charset=utf-8",
dataType: "json",
data: params,
success: function (result) {
//alert("Data Loaded: " + result.d);
var resultData = result.d;
alert(resultData);
$jq.each(resultData.split('|'), function (city, value) {
//alert(this);
alert(city + ': ' + value);
});
},
error: function (xhr, status, error) {
alert('Fejl ved webservice: error: ' + error);
}
};
$jq.ajax(request);
}