I'm a bit stuck, but this has to be user error; the following works, in a sense. It's adding new options to the select but there's a new option for every character in the JSON response, e.g.
Select form
{
[
"
N
a
m
e
"
:
and so on.
Firebug Lite logs the JSON response as:
{"d":"[{\"Name\":\"Monday\"},{\"Name\":\"Tuesday\"},{\"Name\":\"Wednesday\"}]"}
Here is the page source:
<script type="text/javascript">
$(document).ready(function () {
$.ajax({
type: 'POST',
contentType: 'application/json; charset=utf-8',
url: '/MyWebService/MyWebService.asmx/GetDays',
dataType: 'json',
data: '{"_category":"Administration"}',
success: function (response) {
// Clear the list and add an instructional item...
$("#FormsSelect").get(0).options.length = 0;
$("#FormsSelect").get(0).options[0] = new Option("Select form", "-1");
// Add each element returned from the server...
$.each(response.d, function (index, category) {
$('#FormsSelect').append(
$('<option></option>').val(index).html(category)
);
});
},
error: function (request, error) {
alert("An error occurred: " + request.status + "\n" + request.responseText);
}
});
});
</script>
Thoughts on why this is occurring?
Thanks, Aaron.