jsp file code:-
Ajax JSP Code:-
For my testing purpose when i write
on submit button click event i get null value in console but values is get displayed in JSP main page.
Prasad Krishnegowda wrote:Try this
request.getParameter returns the value not the innerHTML..
I have provided you whole file code...just go through it..
"ddlFlat" which is also ajax processing... that value retrieving properly in page and in also request.getparameter but the emp value is retrieving properly in page but null when try to get request.getparameter value
Prasad Krishnegowda wrote:Remove the id emp from div and put it to the input tag with name emp..
You have got a lot to fix in the code, first thing is no Java inside JSP, its been discredited for 10 years now.
Next, JSP's should be used only as a view, all other processing should be done in the servlets..
I have used "getElementByID" method to retrieve the value from Ajax processing page so how can that be done ?
and "document.getElementById("emp").value=xmlHttp1.responseText" when i use this value not printed on jsp page so switched to innerHTML one.
And i know you are talking about MVC but my org. forced me to do whole processing in one JSP page so cant help it.
Sagar Dumbre wrote:i know you are talking about MVC but my org. forced me to do whole processing in one JSP page so cant help it.
If can't believe why the organization(I believe you refer your manager/lead as organization?) don't wan't to get into good practices...
If what you said is correct, then it might well be a good option, to spend some time on Naukri or Monster..
EDIT: i just saw your code, you are returning the whole input tag element only as the AJAX response..
Define the input tags in JSP and just return the values as AJAX response, and use the getElementById('').value to set the AJAX responses to the appropriate fields..