title: Pass object from asp-c# to jquery
body: <p>i want to pass an object from c# to jquery but it didn't work. Here is my code
  c#:</p>
  
  <pre><code>public class ImgLink
  {
      public string img;
  }
  
  [WebService(Namespace = "")]
  [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
  [ScriptService]
  public class ImgService : WebService
  {
      List&lt;ImgLink&gt; Imgs = new List&lt;ImgLink&gt;{
          new ImgLink{img="/kazvan-1.jpg"},
          new ImgLink{img="/kazvan-2.jpg"},
          new ImgLink{img="/wojno-3.jpg"}
      };
      [WebMethod]
      public List&lt;ImgLink&gt; GetAllImgs()
      {
          return Imgs;
      }
  }
  </code></pre>
  
  <h2>Script:</h2>
  
  <pre><code>function getImgs() {
       var myArray = [];
       $.ajax({
           type: "POST",
           url: "ImgService/GetAllImgs",
           data: "{}",
           contentType: "application/json; charset=utf-8",
           dataType: "json",
           success: function (response) {
               var cars = response.d;
               $.each(cars, function (index, car) {
                   myArray.push({ "image": +car.img });
               });
               alert("success");
           },
           failure: function (msg) {
               alert("fail");
           }
      });
      return myArray;
  }
  </code></pre>
  
  <p>my result: MyArray has nothing.</p>
  
  <p>expected result: </p>
  
  <pre><code>myArray = [{ image: '/kazvan-1.jpg' },{ image: '/kazvan-2.jpg' },{ image: '/wojno-3.jpg' }]
  </code></pre>