提取和搜索HTML正文中显示的json响应

时间:2015-11-04 07:47:42

标签: javascript jquery json

我将数据发送到服务器,该服务器返回嵌入在html主体中的json响应。我的目的是提取答案以便

  • 保存在mysql数据库中
  • 创建通知

这是我试图使用的java脚本,但它仍然将第一个条件返回为true,即使它搜索的字符串不存在

PAGE JAVASCRIPT

    <script>
$( document ).ready(function() {
    var text = document.body.innerHTML;

    var code_sent = '[status] =&gt; sent';
    var password_recieved = '[pw] =&gt;';

    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>

更新: 添加了响应截图 server response

0 个答案:

没有答案