JS Ajax in html no output or error shown

I changed some of the variables and id’s but the code is the same, there is no output and there is no error shown in the console of the webpage, if anyone is able to find out any issues in this code please help me out.

@aakashmondal111 there is only a slight mistake in the code.
When you have send an http request to the server so then the server responds back with a staus and the readyState of the request. So readyState of 4 corresponds to Request finsihed and response is ready while the status of 200 refers to Ok.
You have put the correct constraints in the onreadystatechange object’s function. But you have used a wrong keyword, it is onreadystatechange not onreadtstatuschange

Also for being at a safer side replace the id of the para tag to any other variable say test because"nan" may cause an error at backend

1 Like

Thank you a lot, that solved the problem, so is onreadystatechange a predefined function for receiving the request?

The “onreadystatechange” property defines a function to be executed when the readyState changes… The “XMLHttpRequest.onreadystatechange” property contains the event handler to be called when the “readyState” property of the “XMLHttprequest” changes.it is a pre defined function

1 Like