I have the following HTML elements whose values I need to INSERT to a database.
<p>You scored :: </p><p id="txtScore1"></p>
<input type="text" placeholder="Your Name" id="name">
This is the sample javascript code suggested at W3schools site to get the task done.
xmlhttp.open("GET","demo_get2.asp?fname=Henry&lname=Ford",true);
xmlhttp.send();
So I tried the following lines in my javascript file:
xmlhttp.open("GET","insert.php?q=&name=" + encodeURIComponent(document.getElementById('name').value + "&txtScore1=" + encodeURIComponent(document.getElementById('txtScore1').innerHTML),true);
xmlhttp.send();
It doesn’t work and in chrome console the error is given as Uncaught Syntax Error. Unexpected Identifier (repeated two times).
Can you please suggest the error I’m doing?
It is a syntax error.
should be