XMLHTTPRequest没有收到来自LotusScript代理的响应

时间:2018-10-15 17:27:01

标签: javascript xmlhttprequest lotusscript

我有一个LotusScript代理,末尾具有以下代码

Set nam = session.Createname(respParty)
Print "Content-type: text/plain"
Print nam.Abbreviated

我在提交()之前有一个JavaScript按钮,其中包含以下内容

    var noEmployees = document.getElementById('NoEmployees').value;
    var stateName = document.getElementById('State').value;
    var url = 'http://' + window.location.host + '/ebsprospects.nsf/GetResponsiblePerson?OpenAgent&NoEmployees=' + noEmployees + '&State=' + stateName;     
    var xhttp = new XMLHttpRequest();
    xhttp.open("GET", url);

    xhttp.onreadystatechange = function() {
    if (this.readyState == 4 && this.status == 200) {           
        }
    };
    alert (xhttp.responseText);
    document.getElementById("ResponsibleParty").innerHTML = xhttp.responseText;

除返回空白值外,其他所有操作均正常。

如果我输入网址:

  

http://[webaddress]/[dbname].nsf/GetResponsiblePerson?OpenAgent&NoEmployees=20&State=IL

完全按照我将其传递给它返回的JS代码的方式进入浏览器:

    X Content-type: text/plain Susanne Anderson/CBS

我在做什么错?

我的JS代码顺序错误吗?

1 个答案:

答案 0 :(得分:2)

 var noEmployees = document.getElementById('NoEmployees').value;
    var stateName = document.getElementById('State').value;
    var url = 'http://' + window.location.host + '/ebsprospects.nsf/GetResponsiblePerson?OpenAgent&NoEmployees=' + noEmployees + '&State=' + stateName;     
    var xhttp = new XMLHttpRequest();
    xhttp.open("GET", url);

    xhttp.onreadystatechange = function() {
    if (this.readyState == 4 && this.status == 200) {          
         alert (xhttp.responseText);
         document.getElementById("ResponsibleParty").innerHTML = xhttp.responseText;
        }
    };
    xhttp.send();

希望这会有所帮助。