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:
[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
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,