var questionOptionArray=[{"questionCode":"1111111177","optionCode":"1111111147"}, {"questionCode":"1111111103","optionCode":"test"},{"questionCode":"1111111104","optionCode":"1111111212"},{"questionCode":"1111111105","optionCode":"1111111215"},{"questionCode":"1111111106","optionCode":"test2"}]
var jsonobj = JSON.stringify(questionOptionArray);
alert(jsonobj);
$.ajax({
type: "POST",
url: "Services/Quiz.asmx/InsertUserQuiz",
data: JSON.stringify({ questionOptionArray: questionOptionArray }),
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function(data) { alert(data); },
failure: OnError
});
}
在 quiz.asmx 我的代码:
public class Quiz : System.Web.Services.WebService
{
public class optionDetail
{
string questionCode { get; set; }
string optionCode { get; set; }
}
[WebMethod]
public string InsertUserQuiz(List<optionDetail> questionOptionArray)
{
var count = questionOptionArray.Count();
return "1";
}
}
我得到了有五个计数的 questionOptionArray 的空值。,如何在 Web 服务中获取 questionCode、optionCode 的值,以便我可以将它们插入数据库。