質問

次のAJAX関数があります。

function ajax(value, url, urlVarname, displayContainers_id){    
    if(value == ''){
        document.getElementById(displayContainers_id).innerHTML='';
    }
    /* THIS IS LINE 12*/ xmlhttp = new XMLHttpRequest();
    xmlhttp.onreadystatechange=function()
    {
        if(xmlhttp.readyState == 4 && xmlhttp.status == 200){
            document.getElementById(displayContainers_id).innerHTML=xmlhttp.responseText;
        }

    }
    xmlhttp.open('GET',url + '?varName=' + urlVarname + '&value=' + value, true);
    /* THIS IS LINE 25 */ xmlhttp.send();
}

 onmousedown="ajax(document.getElementById('searchParamater').value, 'http://192.168.0.7/controllers/search_controller.php', document.getElementById('searchBy').value, 'ajaxBucket')">

この全体はFirefoxでは正常に機能しますが、Prism 0.9を使用すると、誤動作し、エラーコンソールで次のエラーが発生します。


Warning: assignment to undeclared variable xmlhttp Source File: http://192.168.0.7/javascript/main.js Line: 12

Error: uncaught exception: [Exception... "Not enough arguments [nsIXMLHttpRequest.send]" nsresult: "0x80570001 (NS_ERROR_XPC_NOT_ENOUGH_ARGS)" location: "JS frame :: http://192.168.0.7/javascript/main.js :: ajax :: line 25" data: no]

役に立ちましたか?

解決

var xmlhttp、およびpass "" .send()へ。それでおしまい。

他のヒント

var xmlhttp = new XMLHttpRequest();

ここで推測しています。

他の(より深刻な)問題については、ここに私が見つけたページがあります: https://developer.mozilla.org/en/nsixmlhttprequest

おそらく、プリズムの内部は、あなたが本当にブラウザのページの中にいるのとは異なる環境にいるという事実が違いを生むでしょう。

@pointyが言うように、宣言します xmlhttp 変数。

また、25行目の場合、jQuery(例として)の対応する行は次のとおりです。

xhr.send( type === "POST" || type === "PUT" || type === "DELETE" ? s.data : null );

あなたが今までに得ているだけなら、 xmlhttp.send(null) 大丈夫だろう。

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top