0

I am trying to submit a form to a controller from a javascript but the form button is not showing.

This is my attempt

 for (var i = 0; i < json.length; i++) {
                        users += '<strong>' + json[i].email + '</strong><br/>'  + '<br/>' + json[i].tok + '<hr><br/>';


                        //trying to hit to the controller from here but it is not working
                        //trying to hit to the controller from here but it is not working
                '<form method="post" action="searchAdmin" novalidate="novalidate">'
                '<input type="email" value="json[i].email" name="searchName" id="searchName"/>'
                 //on clicking the fetch button let it submit to the controller
                 '<input type="submit" value="FETCH" />'
                 '</form>'

Kindly assist!

10
  • the input - closing tag seems to be missing Commented Sep 23, 2016 at 8:37
  • I added it but still the same. Even on inspecting element, the form does not show Commented Sep 23, 2016 at 8:40
  • This question basically has nothing to do with Spring at this moment. Commented Sep 23, 2016 at 8:42
  • Is the deployed code up-to-date? Commented Sep 23, 2016 at 8:42
  • Yes. the deployed code is up to date Commented Sep 23, 2016 at 8:43

2 Answers 2

1
user+='<form met....  

because you have used ; on the first line so you need to append this string

Sign up to request clarification or add additional context in comments.

5 Comments

please how do I retrieve the raw value value="json[i].email"
Yes. I have appended it but it is not returning the actual value of value="json[i].email"
@Francis the button is visible now?
Yes it is but its not its not treating this json[i].email as a value
alert it and see if there is some value or not..if there is the value then do it liek this value="'+json[i].email+'"
0

Could you try making the form a single string? Try like below;

//trying to hit to the controller from here but it is not working
                    '<form method="post" action="searchAdmin" novalidate="novalidate"><input type="email" value="json[i].email" name="searchName" id="searchName"/><button type="submit">FETCH</button></form>'

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.