Hi
I am trying to retrieve asp.net C# List method in JavaScript by referring Send-and-receive-JavaScript-Array-to-Web-Service-Web-Method-using-ASP.Net-AJAX
My Code as below
Javascript
<script type = "text/javascript">
function GetAllSVGData() {
PageMethods.GetSvgElements(OnSuccessSVGElements);
}
function OnSuccessSVGElements(response) {
alert('Hi');
for (var i in response) {
alert(response[i]);
}
}
</script>
C#
[System.Web.Services.WebMethod]
public static List<System.Xml.Linq.XElement> GetSvgElements()
{
XDocument doc = XDocument.Load(System.Web.HttpContext.Current.Server.MapPath("~/NewFolder1/10000.svg"));
XNamespace ns1 = "http://www.w3.org/2000/svg";
List<System.Xml.Linq.XElement> Svgelements = new List<System.Xml.Linq.XElement>();
foreach (System.Xml.Linq.XElement elem in doc.Descendants(ns1 + "g"))
{
Svgelements.Add(elem);
}
return Svgelements;
}
HTML
<body onload="GetAllSVGData()">
<form id="form1" runat="server">
<div>
<asp:ScriptManager ID="ScriptManager1" runat="server" EnablePageMethods = "true">
</asp:ScriptManager> </div>
</form>
</body>
My problem is JavaScript function OnSuccessSVGElements is not firing. When I put breakpoints in it is working fine in C#. C# Method Working But Alerts in javascript not working
Can you suggest me where I went wrong? That would be great help for me
Many Thanks
Narasappa