if ajax.responseText contains

2.4k Views Asked by At

i'd like to check for a presence of a particular word in the response text and perform some conditions there after, how do i do that. so far i can only get a "true" from 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);
          }
      }
  }
1

There are 1 best solutions below

1
On

you can use indexOf

if (!(ajax.responseText.indexOf('yourword') == -1)) {
   //do something
}