コンセプトの入力フィールドがあり、ユーザーが入力すると、コンセプトが存在するかどうかを確認する必要があります。そこで、ajax と JavaScript を使用してデータベースをチェックし、概念が存在するかどうかを確認するチェック ボタンを作成しました。私の問題は、ajax と JavaScript を使用すると、次の例外が発生することです。
入力の予期しない終了
JS:
var concept = document.getElementById('acConceptName').value;
xmlhttp = new XMLHttpRequest();
xmlhttp.onreadystatechange=function(){
if(xmlhttp.readyState==4 && xmlhttp.status==200){
var isexisted = JSON.parse(xmlhttp.responseText);
if(isexisted[0]==true){
var errorMessage = document.getElementById('acSuggesConcepts');
var p = document.createElement('p');
p.innerHTML="this concept is already existed";
errorMessage.appendChild(p);
errorMessage.style.display="block";
}
}
}
xmlhttp.open("GET","http://localhost/Mar7ba/Ontology/isExistedConcept/"+concept+"/TRUE",true);
xmlhttp.send();
例外とは何ですか?どうすれば解決できますか?
PHP:データベースをチェックする関数で、常にtrueを返します
public function isExistedConcept($concpetName,$Ajax){
if($Ajax==true){
$results=true
$d=array($results);
return json_encode($d);
}
}