Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/three.js/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Jquery 将数据数组作为参数从Json传递到wcf函数_Jquery_Asp.net_Ajax_Wcf_Json - Fatal编程技术网

Jquery 将数据数组作为参数从Json传递到wcf函数

Jquery 将数据数组作为参数从Json传递到wcf函数,jquery,asp.net,ajax,wcf,json,Jquery,Asp.net,Ajax,Wcf,Json,大家好,我正在使用json在wcf服务中传递数据。下面是我的代码。我能够传递数据ProjectCollection 但我想像这样以数组的形式传递数据 var ProjectCollection=['new','test','etc'] var ProjectCollection = "Test"; function GetEmployee() { Type = "GET"; Url = "http://localhost:52136/Service

大家好,我正在使用json在wcf服务中传递数据。下面是我的代码。我能够传递数据ProjectCollection

但我想像这样以数组的形式传递数据

var ProjectCollection=['new','test','etc']

var ProjectCollection = "Test";      
  function GetEmployee() {
        Type = "GET";
        Url = "http://localhost:52136/Service1.svc/GetTimesheetEntries";
        DataType = "jsonp";
        Data = {vb: ProjectCollection,vb1: '1'};
        ProcessData = false;
        method = "GetTimesheetEntries";
        CallService();
    }

 function CallService() {
        $.ajax({
            type: Type, //GET or POST or PUT or DELETE verb
            url: Url, // Location of the service
            data: Data, //Data sent to server
            contentType: ContentType, // content type sent to server
            dataType: DataType, //Expected data format from server
            processdata: ProcessData, //True or False
            success: function (msg) {//On Successfull service call
                ServiceSucceeded(msg);
            },
            error: ServiceFailed// When Service call fails
        });
    }
这是我的Web服务功能。因此,我的要求是将所有数组数据从json获取到此函数参数

 public List<WcfService1.Customer> GetTimesheetEntries(string[] vb , string vb1)
    {
        DataClasses1DataContext i = new DataClasses1DataContext();
        //var b = from vb in i.TimeSheetMasters select vb;
        //return b.ToList();

        var list = from time in i.TimeSheetMasters
                   join activity in i.ProjectMasters
                   on time.ProjectId equals activity.ProjectId
                   join res in i.ResourceMasters on time.ResourceId equals res.ResourceId
                   where time.TaskDetails == vb && time.BookHours == vb1
                   select new WcfService1.Customer
                   {
                       RName = res.ResourceName,
                       PName = activity.ProjectTitle
                   };

        return list.ToList();


    }
公共列表GetTimesheetEntries(字符串[]vb,字符串vb1)
{
DataClasses1DataContext i=新DataClasses1DataContext();
//var b=从i.时间表中的vb选择vb;
//返回b.ToList();
var list=从i.TimeSheetMasters中的时间
参加i.ProjectMasters的活动
on time.projectd等于activity.projectd
按时将res加入i.ResourceMasters。ResourceId等于res.ResourceId
其中time.TaskDetails==vb&&time.BookHours==vb1
选择新的WcfService1.Customer
{
RName=res.ResourceName,
PName=activity.ProjectTitle
};
return list.ToList();
}
我找到了解决方案

  function GetTimeSheet() {
    //webserviceurl[2]
    Type = "GET";
    Url = "http://gtsp12:3030/Service1.svc/GetTimesheetEntries";
    DataType = "jsonp";
    Data = { Projects: JSON.stringify(projectlist), Resources: JSON.stringify(Resourcelist) };
    method = "GetTimesheetEntries";
    CallService1();
}
只需在脚本中创建数组。初始化它并像上面那样在webservice中作为参数传递