0

我想检查响应文本中是否存在特定单词并在之后执行一些条件,我该怎么做。到目前为止,我只能从 php 中获得“真实”

 function checkCellNo() {

      var cnv = _("CellNo").value;

      if (cnv != "") {

          $("#CellNostatus")
              .html('Checking your number: ...')
              .css('background-image', 'url(images/IMG_8482.GIF)')
              .append($('#CellNo').val());

          var ajax = ajaxObj("POST", "ucheck.php");

          ajax.onreadystatechange = function () {

              if (ajaxReturn(ajax) == true) {
                  _("CellNostatus").innerHTML = ajax.responseText;
              }

              ajax.send("CellNocheck=" + cnv);
          }
      }
  }
4

1 回答 1

1

您可以使用indexOf

if (!(ajax.responseText.indexOf('yourword') == -1)) {
   //do something
}
于 2013-08-15T08:45:26.920 回答