[Solved] Error in Ajax Function [closed]


You add two “});”… see below
your code

function ChangePassword() {
  var email = $("#txtForgotPassEmail").val();
  if (email == "") {
    alert("Please enter the Email ID.")
  } else if (!ValidateEmail(email)) {
    alert("please enter valid Email ID.")
  } else {
    $.ajax({
      type: "POST",
      dataType: "json",
      data: {
        "email": email
      },
      url: "/MainIndex/forgotPassword",
      success: function(val) {
        if (val == "0") {
          alert("Please enter the Valid Email ID.")
          $("#txtForgotPassEmail").val("");
        } else {
          $("#ForgotPassDiv").hide();
          $("#ChangePassDiv").show();
        }
      }
    });
  }
});
}

After change

function ChangePassword() {
  var email = $("#txtForgotPassEmail").val();
  if (email == "") {
    alert("Please enter the Email ID.")
  } else if (!ValidateEmail(email)) {
    alert("please enter valid Email ID.")
  } else {
    $.ajax({
      type: "POST",
      dataType: "json",
      data: {
        "email": email
      },
      url: "/MainIndex/forgotPassword",
      success: function(val) {
        if (val == "0") {
          alert("Please enter the Valid Email ID.")
          $("#txtForgotPassEmail").val("");
        } else {
          $("#ForgotPassDiv").hide();
          $("#ChangePassDiv").show();
        }
      }
    });
  }
/* you add extra }); */
}

FOR MORE JQUERY SOLUTION AND EXAMPLE VISIT

solved Error in Ajax Function [closed]