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
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
My AJAX js code is not running neither it is showing any error. I tried troubleshooting it using given solutions but still i cannot able to detect the mistake. i request to please check it once and tell me the mistake.
@chauhankirti2106 you have done a small typo mistake. In httpRequest object there is a method named as onreadystatechange. So write httpRequest.onreadystatechange and the code will run correctly
i have written it correctly i guess. what changes should i make now?
Here, @vishalvats2000 means to say is JS is case sensitive, so you have to use the exact cases (lower & upper case letters).
onreadystatechange all the letters are in lowercase. Make sure to match the changes for any other keyword in the code as well.
Let me know if you have any other queries.
I got this. Thankyou!
i am getting the correct output. Thankyou