I am sending data to a server which returns a json response which is embedded in the html body. My intention is to extract the responses in order to
- Save in a mysql database
- create notifications
This is the java script I am trying to use but it keeps returning the first condition as true even if the string it's searching for doesn't exist
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>