Sending array of objects to WCF

后端 未结 3 1050
佛祖请我去吃肉
佛祖请我去吃肉 2021-01-23 15:39

In my application i want to save the data by using jQuery and Ajax.I have a WCF Service. I want to save a List of Objects by using ajax.I have tried with following code, but it

3条回答
  •  -上瘾入骨i
    2021-01-23 16:02

    May be this one is the error:

    //creating list of objects
      for(var i=0;i<5;i++)
       {   var MyEntity=new Object();
           MyEntity.TestId =i;
           MyEntity.TestId =i+"testName";
           listOfObjects.push(MyEntity);
       } //-------------------^--------------shouldn't it be capital M
    

    and in the ajax function:

    $.ajax({
            type: "POST",
            async: false,
            data: {data : JSON.stringify(listOfObjects)}, //<---not quite sure about it.
    

提交回复
热议问题