code_junkie

Jquery's Ajax Property For Asp.Net 2.0

Nov 12th, 2011
53
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.32 KB | None | 0 0
  1. $.ajax({
  2. type: "POST",
  3. contentType: "application/json; charset=utf-8",
  4. url: "WebService.asmx/HelloWorld",
  5. data: "{}",
  6. dataType: "json",
  7. success: function(msg) {
  8. alert(msg.d);
  9. }
  10. });
  11.  
  12. [System.Web.Script.Services.ScriptService]
  13. public class Service : System.Web.Services.WebService
  14.  
  15. [ScriptMethod(ResponseFormat = ResponseFormat.Json)]
  16.  
  17. $(document).ready(function() {
  18. $('#clKaydet').click(function() {
  19. $.ajax({
  20. type: "POST",
  21. contentType: "application/json; charset=utf-8",
  22. url: "WebService.asmx/HelloWorld",
  23. data: "{}",
  24. dataType: "json",
  25. success: function(msg) {
  26. alert(msg);
  27. }
  28. });
  29.  
  30. });
  31.  
  32. });
  33.  
  34. <form id="form1" runat="server">
  35. <asp:ScriptManager ID="ScriptManager1" EnablePageMethods="true" runat="server" />
  36. <div>
  37.  
  38. <input type="button" id="clKaydet" runat="server" value="Kayıt" onclick="Kayit()" />
  39. </div>
  40.  
  41. </div>
  42. </form>
  43.  
  44. <WebMethod()> _
  45. Public Function HelloWorld() As String
  46. Dim sText As String = "Hello"
  47. Return sText
  48. End Function
Add Comment
Please, Sign In to add comment