Skip to content Skip to sidebar Skip to footer

How To Write A AJAX GET Request With Two Parameters Taken From Html File?

I have the following HTML elements whose values I need to INSERT to a database.

You scored ::

Solution 1:

It is a syntax error.

xmlhttp.open("GET","insert.php?q=&name=" + encodeURIComponent(document.getElementById('name').value + "&txtScore1=" + encodeURIComponent(document.getElementById('txtScore1').innerHTML),true);

should be

xmlhttp.open("GET","insert.php?q=&name=" + encodeURIComponent(document.getElementById('name').value) + "&txtScore1=" + encodeURIComponent(document.getElementById('txtScore1').innerHTML),true);
//                                                                                                 ↑
//                                                                                        Added parenthesis                                               

Post a Comment for "How To Write A AJAX GET Request With Two Parameters Taken From Html File?"