0
trueまたはfalseのwebmethod応答を解析するif文を含めることを試みています。私はちょうど、応答が真である場合に投稿が成功したこと、または応答が偽であれば投稿が成功しなかったことをユーザーに警告する必要があります。WebMethodの応答と使用If文応答に基づいてユーザーに警告する
私はxhttp.responseTextを使用して応答を得ることができますが、私は私のjavascriptの内部に以下のif文の中にそれを構築する方法を見つけ出すことはできません。
//JavaScript that Posts to WebMethod
<script>
function createNewComment() {
var xhttp = new XMLHttpRequest();
var url = "http://localhost:57766/PALWebService.asmx/insertComment"
var a = document.getElementsByName("existingguid")[0].value;
var b = document.getElementsByName("newcomment")[0].value;
var c = 'existingguid=' + a + '&newcomment=' + b;
xhttp.open("POST", url, true);
xhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
xhttp.onreadystatechange = function() {
if (this.readyState == 4 && this.status == 200) {
}
};
xhttp.send(c);
}
</script>