Vikas Singh

Vikas Singh

  • 1.2k
  • 391
  • 13.5k

I am unable to call ajax method

Jan 31 2021 5:14 PM
Hello when i am calling this function showing error in---
  1. $.ajax({  
  2. <form id="form1" runat="server">  
  3. <h3>Register Vendor</h3>  
  4. <div class="form-group">  
  5. <asp:TextBox runat="server" ID="txtfirstname" MaxLength="20" type="text" placeholder="First Name" class="form-control"  
  6. onkeyDown="checkTextAreaMaxLength(this,event,'20');" />  
  7. <asp:TextBox runat="server" ID="txtlastname" MaxLength="30" type="text" placeholder="Last Name" class="form-control"  
  8. onkeyDown="checkTextAreaMaxLength(this,event,'30');" />  
  9. <%--<asp:RequiredFieldValidator runat="server" ControlToValidate="txtfirstname" Display="None" ValidationGroup="vendorSignup" ErrorMessage="First Name is required !"></asp:RequiredFieldValidator>  
  10. <asp:RequiredFieldValidator runat="server" ControlToValidate="txtlastname" Display="None" ValidationGroup="vendorSignup" ErrorMessage="Last Name is required !"></asp:RequiredFieldValidator>--%>  
  11. </div>  
  12. <div class="form-wrapper">  
  13. <asp:TextBox runat="server" ID="txtusername" MaxLength="35" type="text" placeholder="Username" class="form-control"  
  14. onkeyDown="checkTextAreaMaxLength(this,event,'35');" />  
  15. <%--<asp:RequiredFieldValidator runat="server" ControlToValidate="txtusername" Display="None" ValidationGroup="vendorSignup" ErrorMessage="Username is required !"></asp:RequiredFieldValidator>--%>  
  16. <i class="zmdi zmdi-account"></i>  
  17. </div>  
  18. <div class="form-wrapper">  
  19. <asp:TextBox runat="server" ID="txtemail" MaxLength="40" type="emil" placeholder="Email ID" class="form-control"  
  20. onkeyDown="checkTextAreaMaxLength(this,event,'40');" />  
  21. <%--<asp:RequiredFieldValidator runat="server" ControlToValidate="txtemail" Display="None" ValidationGroup="vendorSignup" ErrorMessage="Email ID is required !"></asp:RequiredFieldValidator>--%>  
  22. <i class="zmdi zmdi-email"></i>  
  23. </div>  
  24. <div class="form-wrapper">  
  25. <asp:TextBox runat="server" ID="txtmobile" MaxLength="10" type="number" placeholder="Mobile Number" class="form-control"  
  26. onkeyDown="checkTextAreaMaxLength(this,event,'10');" />  
  27. <%--<asp:RequiredFieldValidator runat="server" ControlToValidate="txtmobile" Display="None" ValidationGroup="vendorSignup" ErrorMessage="Mobile Number is required !"></asp:RequiredFieldValidator>--%>  
  28. <i class="zmdi zmdi-phone"></i>  
  29. <%--<i class="zmdi zmdi-caret-down" style="font-size: 17px"></i>--%>  
  30. </div>  
  31. <div class="form-wrapper">  
  32. <asp:TextBox runat="server" ID="txtpassword" MaxLength="20" type="password" placeholder="Password" class="form-control"  
  33. onkeyDown="checkTextAreaMaxLength(this,event,'20');" />  
  34. <%--<asp:RequiredFieldValidator runat="server" ControlToValidate="txtpassword" Display="None" ValidationGroup="vendorSignup" ErrorMessage="Password is required !"></asp:RequiredFieldValidator>--%>  
  35. <i class="zmdi zmdi-lock"></i>  
  36. </div>  
  37. <div class="form-wrapper">  
  38. <asp:TextBox runat="server" ID="txtconfirmpassword" MaxLength="20" type="password" placeholder="Confirm Password" class="form-control"  
  39. onkeyDown="checkTextAreaMaxLength(this,event,'20');" />  
  40. <%--<asp:RequiredFieldValidator runat="server" ControlToValidate="txtconfirmpassword" Display="None" ValidationGroup="vendorSignup" ErrorMessage="Confirm Password is required !"></asp:RequiredFieldValidator>--%>  
  41. <i class="zmdi zmdi-lock"></i>  
  42. </div>  
  43. <button id="btnsubmit" onclick="VendoRegistrationvalidation();">  
  44. Register  
  45. <i class="zmdi zmdi-arrow-right"></i>  
  46. </button>  
  47. </form>  
  48. <script>  
  49. function VendoRegistrationvalidation() {  
  50. if (document.getElementById('txtfirstname').value == "") {  
  51. alert('First Name is required !');  
  52. return false;  
  53. }  
  54. if (document.getElementById('txtlastname').value == "") {  
  55. alert('Last Name is required !');  
  56. return false;  
  57. }  
  58. if (document.getElementById('txtusername').value == "") {  
  59. alert('User Name is required !');  
  60. return false;  
  61. }  
  62. if (document.getElementById('txtemail').value == "") {  
  63. alert('Email is required !');  
  64. return false;  
  65. }  
  66. if (document.getElementById('txtmobile').value == "") {  
  67. alert('Mobile Number is required !');  
  68. return false;  
  69. }  
  70. if (document.getElementById('txtpassword').value == "") {  
  71. alert('Password is required !');  
  72. return false;  
  73. }  
  74. if (document.getElementById('txtconfirmpassword').value == "") {  
  75. alert('Confirm Password is required !');  
  76. return false;  
  77. }  
  78. if (document.getElementById('txtpassword').value != document.getElementById('txtconfirmpassword').value) {  
  79. alert('Please make sure your password match !');  
  80. return false;  
  81. }  
  82. var model = {  
  83. FirstName: document.getElementById('txtfirstname').value,  
  84. LastName: document.getElementById('txtlastname').value,  
  85. Email: document.getElementById('txtemail').value,  
  86. mobile: document.getElementById('txtmobile').value,  
  87. LoginID: document.getElementById('txtusername').value,  
  88. Password: document.getElementById('txtpassword').value  
  89. }  
  90. $.ajax({  
  91. type: 'POST',  
  92. contentType: 'application/json; charset=utf-8',  
  93. data: JSON.stringify(model),  
  94. dataType: 'json',  
  95. cache: false,  
  96. async: true,  
  97. url: '/RegisterVendor.aspx/SignupVendor',//Call server side code  
  98. success: function (result) {  
  99. var vm = JSON.parse(result);  
  100. if (vm.IsExists != "0") {  
  101. if (vm.IsExists === "1") {  
  102. location.href = '/Home'// on Successfull vaildation  
  103. else {  
  104. $('#dis').slideDown().html('<span id="errorLogin">Invalid UserID or Password! or InActive Login</span>');  
  105. }  
  106. else {  
  107. $('#dis').slideDown().html('<span id="errorLogin">Invalid UserID or Password!or InActive Login</span>');  
  108. }  
  109. },  
  110. error: function (xhr, ajaxOptions, thrownError) {  
  111. },  
  112. });  
  113. }  
  114. </script>  

Answers (3)