Click here to Skip to main content
15,889,877 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi all,
Client Side:
------------
API.getDetails = function (id) {

        return $http.post("webservices/WebService1.asmx/getDetails"
       ,JSON.stringify({ 'm': { id: "123"} })
        
        )
    }
---------

      APIservice.getDetails($scope.id).then(function (data, status, headers, config) {
          console.log(data.data);
          $scope.details = data.data;

      },
      function (data) { console.log(data); alert(data); }

      );

Server Side:
C#
                [WebMethod]
[ScriptMethod( UseHttpGet=false, ResponseFormat = ResponseFormat.Json)]
public void getDetails(lst m)
{
    try
    {
        List<Volumes> l = new List<Volumes>();
        l.Add(new Volumes { name= "TEST123", options = "10", shares = "10", stocks = "10", tickets = "10" });

        JavaScriptSerializer js = new JavaScriptSerializer();
        Context.Response.Clear();
        Context.Response.ContentType = "application/json;charset=utf-8";

       Context.Response.Write(js.Serialize(l));
    }
    catch (Exception ex) { throw ex; }
}


when I call the getDetails method then method call successfully and js.Serialize(l) create correct json but the on client side
angular.js

JavaScript
function fromJson(json) {
  return isString(json)
      ? JSON.parse(json)
      : json;
}


where json has extra {d:null} !!!!!!!!
"[{"mpid":"TEST123","shares":"10","stocks":"10","options":"10","tickets":"10"}]{"d":null}"



but when I remove the ,
JSON.stringify({ 'm': { id: "123"} })
and
lst m
then no error show. But i want pass param as well.


can you tell me where is issue?

Thanks all,
Posted

1 solution

why don't you try:

JavaScript
$http.post("webservices/WebService1.asmx/getDetails?id=123")
 
Share this answer
 
Comments
zeeShan anSari 1-Apr-14 11:07am    
oK...but i want pass json data and it can be huge data. For example I want pass grid data to server side.
I can fix this issue by change in angular.js and where replace the {"d":null} and it is working!

Thanks,

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900