passing Data array from Json to wcf function as argument

Hi all i am using json to pass data in wcf service. Below is my code. I am able to pass data ProjectCollection

But i want to pass data as an array like this

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
        });
    }

This is my webservice function. So my requirement is to get all array data from json to this function argument.

 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();


    }

Answers


I Found my Solution

  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();
}

Just create array in your script. Initialize it and pass as an argument in webservice like above.


Need Your Help

jackson with jaxb

java jaxb jax-ws jersey jackson

when using Jackson JSON processor in Jersey, when and why would I need to use JAXB annotations in between? Object-&gt;JAXB-&gt;JSON

How to remove the error tip after jquery.datepicker

jquery validation datetime

I have an input like &lt;input name="begin_time" /&gt;,&lt;input name="end_time" /&gt; I'm using the jquery.datepicker and jquery-ui-timepicker-addon.js to get the datetime.

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.