我将数据发送到服务器,该服务器返回嵌入在html主体中的json响应。我的目的是提取答案以便
这是我试图使用的java脚本,但它仍然将第一个条件返回为true,即使它搜索的字符串不存在
PAGE JAVASCRIPT
<script>
$( document ).ready(function() {
var text = document.body.innerHTML;
var code_sent = '[status] => sent';
var password_recieved = '[pw] =>';
if (text.indexOf(code_sent) >= 0)
{
alert('Code Sent');
window.location.replace("index.php");
}
else if (text.indexOf(password_recieved) >= 0)
{
alert('Password Recieved');
window.location.replace("index.php");
}
});
</script>