我无法获取返回数据的属性。我对原型很陌生。我的错误在哪里?
这是我的代码:
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/prototype/1.7.1.0/prototype.js"></script>
<script>
var xRequest = new Ajax.Request('PrototypeTest.aspx/Test', {
method: 'post',
contentType: 'application/json; charset=utf-8',
onSuccess: function (val) {
var brands= val.responseText.evalJSON();
alert(brands);
},
onerror: function (val) {
alert('hata');
}
});
</script>
[WebMethod]
public static string Test()
{
List<brand> brands = new List<brand>();
brands.Add(new brand()
{
Name = "BMW",
IsActive = true
});
var json = new JavaScriptSerializer();
return json.Serialize(brands);
}