i am having strange issue with yii framework. on localhost, ajax response takes 200ms (which is fast and i am satsified) where as on my live server, same function take 4 to 7 seconds.
below is my php ajax function:-
public function actionOpenpopup() {
$this->checkAjaxRequest();
$user_id = $_GET['uid'];
$rows = Yii::app()->db->createCommand()
->select('*')
->from('saved_designs')
->where('uid=:id', array(':id' => $user_id))
->order('date desc')
->queryAll();
$i = 0;
foreach ($rows as $row) {
$rows[$i] = $row;
$i++;
}
if ($rows) {
echo json_encode($rows);
}
else
echo json_encode(null);
}
function checkAjaxRequest() {
if (Yii::app()->request->isAjaxRequest) {
header('Content-Type: application/json; charset="UTF-8"');
return true;
} else {
throw new CHttpException('403', 'Forbidden Access');
exit;
}
}
javascript code is:-
function sendAjaxCall(data){
$.ajax({
type : 'GET',
url : 'index.php/request/openpopup',
datatype : 'json',
data :data,
success: function (data) {
console.log(data);
}
});
}
*Note:- So far database has only 10 to 20 records. Also On live server, all my ajax calls give me slow response.