-2

在这个功能中,当我使用 firebug 时,我得到“syntaxerror:missing ; before var url 行上的语句。

    function makeRequest(){
                 var url= "contr_entry_pkg.sales_center_dropdown?&pnSalesCenterID=document.getElementById("pnSalesCenterID").value +&pvCurrCd='||CURRDEF||'";
                ajaxReq = (window.XMLHttpRequest)? new XMLHttpRequest() : new ActiveXObject("MSXML2.XMLHTTP")

                ajaxReq.open("POST",url ,true);
                ajaxReq.onreadystatechange =currencychange;         
                ajaxReq.send()         
        } 
4

2 回答 2

3

"尝试在您的 url 字符串中转义:

var url= "contr_entry_pkg.sales_center_dropdown?&pnSalesCenterID=document.getElementById(\"pnSalesCenterID\").value +&pvCurrCd='||CURRDEF||'";

这将修复语法错误,尽管我认为你的意思是这样的:

var url= "contr_entry_pkg.sales_center_dropdown?&pnSalesCenterID=" + 
         document.getElementById("pnSalesCenterID").value +
         "&pvCurrCd='||CURRDEF||'";

此外,您应该(尽管不是严格要求)在每个语句后放置分号:

ajaxReq = (window.XMLHttpRequest)? new XMLHttpRequest() : new ActiveXObject("MSXML2.XMLHTTP"); // <-- added ; here
...
ajaxReq.send(); // <-- added ; here
于 2013-11-05T16:33:09.893 回答
0
function makeRequest(){
                 var url= "contr_entry_pkg.sales_center_dropdown?&pnSalesCenterID=document.getElementById(\"pnSalesCenterID\").value +&pvCurrCd='||CURRDEF||'";
                ajaxReq = (window.XMLHttpRequest)? new XMLHttpRequest() : new ActiveXObject("MSXML2.XMLHTTP")

                ajaxReq.open("POST",url ,true);
                ajaxReq.onreadystatechange =currencychange;         
                ajaxReq.send();      
        } 
于 2013-11-05T16:35:52.510 回答