Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!DOCTYPE html>
- <html lang="en">
- <head>
- <meta charset="UTF-8">
- <title>Search Client Example</title>
- <script>
- function ajaxPost(
- pUrl,
- pWhereToReply,
- pTheData
- ){
- var req = new XMLHttpRequest()
- if(req){
- req.open(
- "POST",
- pUrl,
- true
- )
- req.mWhereToReply = pWhereToReply
- req.onreadystatechange = howToReact
- req.send(pTheData)
- }
- }//ajaxPost
- function howToReact(){
- if (this.readyState===4 && this.status===200){
- this.mWhereToReply.innerHTML = this.responseText
- }
- else{
- this.mWhereToReply.innerHTML = this.readyState
- }
- }//howToReact
- window.onload = boot
- function boot(){
- /*
- var o = document.getElementById("idFeedback")
- var theData = new FormData()
- theData.append("q", "lee")
- ajaxPost(
- "http://localhost:5002/search",
- o,
- theData
- )
- */
- document.getElementById("idForm").onsubmit =
- produzPedido
- }//bot
- function produzPedido(){
- var theData = new FormData(
- document.getElementById("idForm")
- )
- var oReqPost = ajaxPost(
- "http://localhost:5002/search",
- document.getElementById("idFeedback"),
- theData
- )
- return false
- }
- </script>
- </head>
- <body>
- <form
- id="idForm"
- method="post"
- action="http://localhost:5002/search"
- >
- <input type="text" name="q" value="senator" id="idQ">
- <input type="submit" value="fazer pedido">
- </form>
- <section id="idFeedback"></section>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement