$(function(){
$("#checkddl").click(function(){
var ddlgroup = $(".cellgruop");
var sval=$("#ddlweight").get(0).value+'_'+$("#ddlmweight").get(0).value+'_';
for(var i=0;i<ddlgroup.length;i++){
sval = sval+ddlgroup[i].value+'_';
}
//sval的值为1_5_4_2_4_5_这种结构
var pdata = "{value1:"+sval+"}";
$.ajax({
type: "POST",
contentType: "application/json",
url: "WebService.asmx/EvaluationMark",
data: pdata,
dataType: 'json',
success: function(result) {
alert(result);
},error:function(err){
alert(err.responseText);
}
});
});
});
后台代码:
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Services;
using System.Web.Services.Protocols;
using System.Xml.Linq;
using MethodBLL;
using System.Data;
/// <summary>
///WebService 的摘要说明
/// </summary>
[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
//若要允许使用 ASP.NET AJAX 从脚本中调用此 Web 服务,请取消对下行的注释。
[System.Web.Script.Services.ScriptService]
public class WebService : System.Web.Services.WebService
{
[WebMethod]
public string EvaluationMark(string value1)