我有以下HTML元素的值,我需要插入到数据库。如何使用HTML文件中的两个参数编写AJAX GET请求?
<p>You scored :: </p><p id="txtScore1"></p>
<input type="text" placeholder="Your Name" id="name">
这是在W3schools网站上建议的示例javascript代码,以完成任务。
xmlhttp.open("GET","demo_get2.asp?fname=Henry&lname=Ford",true);
xmlhttp.send();
所以,我想下面的线在我的JavaScript文件:
xmlhttp.open("GET","insert.php?q=&name=" + encodeURIComponent(document.getElementById('name').value + "&txtScore1=" + encodeURIComponent(document.getElementById('txtScore1').innerHTML),true);
xmlhttp.send();
它不工作,并且在镀铬控制台错误给出未捕获的语法错误。意外标识符(重复两次)。
您能否提出我正在做的错误?
谷歌浏览器会告诉你在行你所得到的错误。张贴这些线,以便可以看到他们有什么问题。 – zizoujab 2012-08-05 14:23:28
问题通过@joar解决 – 2012-08-05 14:49:31