我在ubuntu下架了一个boa的服务器
html页面上调用avcon_set()总是提示502 - Bad Gateway 错误。
服务器的cgi-bin/admin下放了一个avconsetting.lua的服务本,内容为
#!/usr/bin/lua
print("succeed")
客户端js脚本如下:
function createxmlhttprequest(){
var xmlhttp=false;
try{
xmlhttp=new ActiveXObject("Msxm12.XMLHTTP");
}catch(e){
try{
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
catch(e){
try{
xmlhttp=new XMLHttpRequest();
}catch(e){
} } }
return xmlhttp;
}
function avcon_set()
{
var xmlhttp=createxmlhttprequest();
//xmlhttp.responseXML;
xmlhttp.open("POST", "/cgi-bin/admin/avconsetting.lua", true);
xmlhttp.onreadystatechange=function(){
if(xmlhttp.readyState==4){
if(xmlhttp.status==200){
alert("ok");
/*if (s==2 && unescape(xmlhttp.responseText) == "succeed"){
alert("succeed");
}else if(s !=2 || unescape(xmlhttp.responseText) == "failed"){
alert("failed");
}*/
}
else
{
alert("error:"+ xmlhttp.status + ":" + xmlhttp.statusText);
}}}
xmlhttp.send(null);
}
html页面上调用avcon_set()总是提示502 - Bad Gateway 错误。
你可以试试在lua脚本前面加上
io.write("Content-Type: text/plain\n\n")
对于CGI来说 Content-Type 是必不可少