dud当我使用 ajax 调用我的 php 文件时,几乎需要整整 30 秒才能显示任何结果。
我怎样才能使结果更加即时?
我的ajax是:
$("#j_search").keyup(function(){
if(($.trim($(this).val()) != '') & ($(this).val() != ' ')){
$.post('../php/ajax/j_search.php', {search: $(this).val()}, function(data){
$(".matched_results").html(data).show();
});
}
});
如果您出于某种原因认为我的 php 错误,请编写您自己的示例,我会对其进行测试,尽管我对此表示怀疑。我不能给出php源代码。
我可能会因为发布代码而被解雇,但在这样的时候似乎值得。这是 PHP 的一个片段:
class SQL_COMMANDS{
//Connecting vars
private $_HOST = "localhost";
private $_USER = "root";
private $_PASS = "dud";
private function HANDLE($ERRORNUM, $ERRORMSG){//USED FOR ERROR HANDLER
$HANDLE = new HANDLE();
$HANDLE->DIRECT($ERRORNUM, $ERRORMSG);
}
function connect($DB){
$con=mysqli_connect($this->_HOST,$this->_USER,$this->_PASS,$DB);
if (mysqli_connect_errno($con)){
$this->HANDLE("001","Connection failed (DB)");
}
return $con;
// mysqli_close($con);
//$SQL_COMMANDS->connect("DB");
}
function SQL($DB, $SQL){//Construct used to transact CONNECT
return mysqli_query($this->connect($DB), $SQL);
// mysqli_close($this->connect($DB));
//$SQL_COMMANDS->SQL("DB", "SELECT * FROM TABLE WHERE ID=1");
}
function Assoc_Grab($DB, $SQL, $ARRAYGRAB){//Returns Data associated with the ARRAY directed from the QUERY
$DATA = array();
$ROW = mysqli_fetch_assoc($this->SQL($DB, $SQL));
foreach($ARRAYGRAB as $pointer){
array_push($DATA,$ROW[$pointer]);
}
//print_r($SQL_COMMANDS->Assoc_Grab('DB', "SELECT * FROM TABLE WHERE ID='1'", array('NAME')));
return $DATA;
}
}