[英]Passing code with a value in a query string appended to the URL in JavaScript/AJAX
I have been looking through different answers to what might be the same question I am asking, and a lot of the solutions have used PHP or JQuery and I have to do this in JavaScript. 我一直在寻找不同的答案,以解决可能要问的同一问题,而且许多解决方案都使用PHP或JQuery,而我必须使用JavaScript来完成。 Here is my problem (and I'm a real noob, so I'm probably doing something really stupid and that's why it's not working). 这是我的问题(我是一个真正的菜鸟,所以我可能正在做一些非常愚蠢的事情,这就是为什么它不起作用的原因)。
I am trying to pass 'code' with a value in a query string appended to the URL. 我正在尝试使用附加到URL的查询字符串中的值传递“代码”。 Then get the code to write dynamically to the page after. 然后获取代码以将其动态写入页面之后。 Right now, I'm receiving the error: "Incorrect code submitted". 现在,我收到错误:“提交的代码不正确”。 I don't think I am sending the "code" correctly. 我认为我没有正确发送“代码”。
I started a jsfiddle too: http://jsfiddle.net/shannongmac/6Z7NR/ 我也开始了jsfiddle: http : //jsfiddle.net/shannongmac/6Z7NR/
Here is my code: 这是我的代码:
function loadXMLDoc() {
var xmlhttp;
if (window.XMLHttpRequest) {// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp=new XMLHttpRequest();
}
else {// code for IE6, IE5
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.onreadystatechange=function() {
if (xmlhttp.readyState==4 && xmlhttp.status==200) {
document.getElementById("myDiv").innerHTML=xmlhttp.responseText;
}
}
xmlhttp.open("GET","http://florence.ccs.uconn.edu/~adepalma/cgi-bin/iskm3120/response.cgi",true);
xmlhttp.send("yowza");
function addText() {
var newParagraph = document.createElement('p');
newParagraph.textContent = textArea.value;
document.getElementById("myDiv").insertBefore(newParagraph, H2);
}
}
You have a couple of problems with your code: 您的代码有两个问题:
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.