0

我有一个存储从 API 返回的信息的函数。

我已经有一个 if 语句告诉用户返回调用的准确性太低。但是我该如何为我的 mysql 语句做同样的事情呢?

if(tag.uid == 0) s += "I got something, but the data wasn't clear. Sorry.";
     if(tag.confidence < 80) {
      s += "<li>User identification accuracy was too low, please try again</li>";
    }
     else if(tag.uid) { s += "<li> User:" + uid + "</li>";
     if(tag.uid) s += "<li> Accuracy:" + tag.confidence + "%" + "</li>";
     if(tag.uid) s += "<li> Timestamp:" + log_time + "</li>";
    }


    } 
    if(photo.tags.length) {
      if (window.XMLHttpRequest) {
        xmlhttp = new XMLHttpRequest();
      }
      xmlhttp.open("GET", "mysql/save.php?uid=" + tag.uid + "&month=" + month + "&day=" + day + "&hours=" + hours + "&min=" + min + "&suffix=" + suffix + "&accuracy=" + tag.confidence,  true);
      xmlhttp.send();
    } 

我认为它与前面的语句几乎相同,但不知道如何编写错误语句,因为我不想提醒用户错误,只是在准确率提高之前不保存任何信息。

4

1 回答 1

0

没关系,其实很简单。

if(photo.tags.length) {
      var tag = photo.tags[0].uids[0];
      s += "<p>";
     //$('#result') .html ('Welcome Back:' + photo.uid + ',' + 'Confidence:' + photo.confidence);
     if(tag.uid == 0) s += "I got something, but the data wasn't clear. Sorry.";
     if(tag.confidence < 80) 
      {
      s += "<li>User identification accuracy was too low, please try again</li>";
      }
     else if(tag.uid) { 
       s += "<li> User:" + uid + "</li>";
       if(tag.uid) s += "<li> Accuracy:" + tag.confidence + "%" + "</li>";
       if(tag.uid) s += "<li> Timestamp:" + log_time + "</li>";
       if (window.XMLHttpRequest) 
        {
          xmlhttp = new XMLHttpRequest();
        }
        xmlhttp.open("GET", "mysql/save.php?uid=" + tag.uid + "&month=" + month + "&day=" + day + "&hours=" + hours + "&min=" + min + "&suffix=" + suffix + "&accuracy=" + tag.confidence,  true);
        xmlhttp.send();
      }
    } 
于 2012-07-06T17:12:38.183 回答