[WebMethod] public string HelloWorld() { string log = "Hello World"; JavaScriptSerializer jss = new JavaScriptSerializer(); string json = jss.Serialize(log); return json; }
<script type="text/javascript" src=" http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script> <script type="text/javascript"> $(document).ready(function(){ $.ajax({ type: "POST", url: "Service.asmx/HelloWorld", data: "{}", contentType: "application/json; charset=utf-8", dataType: "json", success: function(msg) { alert(msg.d); }, error: function(e) { alert("WebSerivce unreachable"); } }); }); </script>
url: "http://localhost:1111/Services/Service.asmx/HelloWorld"
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)