|
■No85864 (k3user さん) に返信
図表モードで試してみます。ダメだったらすみません。
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<title></title>
<script src="Scripts/jquery-1.10.2.js"></script>
<script type="text/javascript">
//<![CDATA[
function getCars() {
$.ajax({
type: "POST",
url: "097_jQueryAjaxAndWebService.asmx/GetCarsByDoors",
data: '{"doors":' + $("#ddlDoors").val() + '}',
contentType: "application/json; charset=utf-8",
success: function (cars) {
$('#output').empty();
$.each(cars, function (index, car) {
$('#output').append(
'<p><strong>' + car.Make + ' ' +
car.Model + '</strong><br /> Year: ' +
car.Year + '<br />Doors: ' +
car.Doors + '<br />Colour: ' +
car.Colour + '<br />Price: £' +
car.Price + '</p>');
});
},
error: function (jqXHR, textStatus, errorThrown) {
$('#output').text('textStatus: ' + textStatus +
', errorThrown: ' + errorThrown);
}
});
}
//]]>
</script>
<meta charset="utf-8" />
</head>
<body>
<div>
Number of doors:
<select name="ddlDoors" id="ddlDoors">
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="5">5</option>
</select>
</div>
<input type="button"
id="Button1"
value="Get Cars"
onclick="getCars();" />
<div id="output"></div>
</body>
</html>
|