0

Can anyone help me understand what I am doing wrong? When you click the send feedback button on my webpage it needs to load a new page that says "Thanks for your feedback!" and then the message from the "customer" should be logged onto the Node server. But I'm getting an error "Form submission canceled because the form is not connected".

Here is the main code that is related to my issue:

function sendFeedback() {

var feedbackform = document.createElement("FORM");                     
feedbackform.name="feedbackform";                                      
feedbackform.method = "POST";                                          
feedbackform.action = "/feedback";                                     
var forminput = document.createElement("INPUT");                       
forminput.type = "TEXT";                                               
forminputname = "feedback";                                            
forminputvalue = final_transcript;                                     
feedbackform.appendChild(forminput);                                   
feedbackform.submit();   
                                            }                                                                                                                                          

I am very new to JavaScript and this is for a course I just started. I just need to understand what I am doing wrong and how to go about fixing it.

This is the code within the server.js file for the customer feedback:

self.createRoutes = function() {
    self.routes = { };

    self.routes['/feedback'] = function(req, res) {
        console.log("-- Received a customer feedback: [" + req.body.feedback + "]");
        res.send("<html><head><title>WTCU Feedback</title></head><body><div style='text-align:center; font-size:24pt'>Thanks for your feedback!</div></body></html>");
    };

    self.routes['/'] = function(req, res) {
        res.setHeader('Content-Type', 'text/html');
        res.send(self.cache_get('index.html') );
    };
};  

Absolutely any help is greatly appreciated. Thank you!

Molly

  • I have more code I wanted to add, but it wouldn't post the question with everything in there....Basically I just need to know how to connect the customer feedback to the server. Thanks! – mminkema Jan 21 '18 at 18:42
  • 1
    Possible duplicate of this https://stackoverflow.com/questions/42053775/getting-error-form-submission-canceled-because-the-form-is-not-connected – David Jan 21 '18 at 21:33

0 Answers0