Didn't get alert message while doing ajax

I didn’t get alert message while doing ajax . I did exact the same steps as it was in the video still didn’t get the output . i have rechecked my code. I am not able to find the error.

Hi @vt15081998,

It seems like you’re trying to get an alert message when a button is clicked using JavaScript. However, there’s a small typo in your code that’s causing the issue. Here’s the corrected code:

<!DOCTYPE html>
<html>
<head>
<title></title>
</head>
<body>
<p id="output">Default text</p>
<input id="user_number">
<button onclick="update_user()">Submit</button>
<script type="text/javascript">
  function update_user() {
    var user_number = document.getElementById("user_number").value;
    alert(user_number);
  }
</script>
</body>
</html>

I’ve made a few corrections to your code:

  1. Changed getElementByID to getElementById.
  2. Added var before user_number to declare it as a variable.

With these changes, your code should work as expected, and you should see an alert message when you click the “Submit” button.

Hi, your code has onw small error. After correction the code snippet becomes:
.
.
.
function update_user(){
user_number = document.getElementById(“user_number”).value;
alert(user_number);
}
.
.
The error was a typo in the getElementById (As the Id was ID in your code).