asp.net - jQuery $.ajax method displays error status -
the webservice looks
using system;<br/> using system.collections.generic;<br/> using system.linq;<br/> using system.web;<br/> using system.web.services;<br/> [webservice(namespace = "http://tempuri.org/")]<br/> [webservicebinding(conformsto = wsiprofiles.basicprofile1_1)]<br/> [system.web.script.services.scriptservice] <br/> public class map : system.web.services.webservice { [webmethod] public mapclass latitudelongitude() { mapclass mapobj = new mapclass(); return mapobj; } [webmethod] public string hellotoyou() { return "hello"; } }
the class like:
public class mapclass <br/> { string latitude; string longitude; public mapclass() { latitude = "51.508742"; longitude = "-0.120850"; } }
and trying call webservice html5 page
`</head>`<br/> `<body>`<br/> `<form id="form1" runat="server">`<br/> `<h1>map</h1>`<br/> `<input id="view" type="button" value="click view" onclick="getdata()"/>`<br/> `</form>`<br/> `</body>`<br/> `<script type="text/javascript" src="d:\pepsico\jquery\jquery-1.7.1.min.js"> </script>`<br/> `<script type="text/javascript">` function getdata() { $.ajax({ type:"post", url: "http://localhost:53788/html5_webservice_maps/map.asmx/hellotoyou", contenttype: "application/json;charset=utf-8", datatype: "json", complete: function (response) { alert('complete'); }, success: function (response) { alert('success'); }, error: function (response) { alert('failure'); } }); } `</script>` `</html>`
when browse html page in chrome, displays failure in alert box. dont know why isnt showing success. please help.
change datatype htmland check
datatype: "html",
Comments
Post a Comment