我的webmethod需要什么签名才能传递'paramlist'作为参数?
$(document).ready(function () {
var slider = $('.slider').slider({
range: "min",
min: 0,
max: 100,
change: function (e, ui) {
var set = new Array();
var values = $('.slider').each(function () {
var s = $(this);
var data = {
Name: s.attr('itemName'),
SelectedIndex: s.slider("option","value"),
Description: "this is the description",
CalculatedValue: 0
}
set.push(data);
});
CallPageMethod("SliderChanged", set, successful, failure);
},
slide: function (e, ui) {
var point = ui.value;
$("#selected_value").html(point);
// var width = 100 - point;
// $("#range").css({ "width": point + "%" });
}
});
function CallPageMethod(methodName, paramArray, onSuccess, onFail) {
//get the current location
var loc = window.location.href;
loc = (loc.substr(loc.length - 1, 1) == "/") ? loc + "default.aspx" : loc;
//call the page method
$.ajax({
type: "POST",
url: loc + "/" + methodName,
data: JSON.stringify(paramArray),
contentType: "application/json; charset=utf-8",
dataType: "json",
success: onSuccess,
fail: onFail
});
}
function successful(response) {
var lbl = $('#')
lbl.html("Your report is now ready for download.");
alert(response.d);
}
function failure(response) {
alert("An error occurred.");
}
});
我试过了:
[WebMethod]
public static string SliderChanged(MyModel[] values)
{
return "success";
}
其中
public class MyModel
{
public string Name {get;set;}
public string Description {get;set;}
public int SelectedIndex{get;set;}
public int CalculatedValue(get;set;}
}
它失败了。
你能发现我的错误吗?