jquery - Caching AJAX results with PHP -
i have ajax call retrieves lines file via json. have 3m rows in database , want show result cannot see anything.
the results retrieved via json wanted cache, if data requested more once, not send request again. best practices caching in jquery?
i use php in server side. suggestions appreciated.
my javascript code:
function getsearchresult(char,company,category,country,page) { $.ajax({ type: "post", url: "companyresult.php", data: { mysearchchar : char, mysearchcompany : company, mysearchcategory : category, mysearchcountry : country, mypage : page }, cache: false, datatype : "html", beforesend: function(){ $("#loading").show(); //show image loading $('html, body').animate({scrolltop:$('#insid_body_web').offset().top}, 'slow'); $("#resultcompany1").hide(); $("#resultcompany2").hide(); $("#errorsearch").hide(); }, complete: function(){ $("#loading").hide(); //hide image loading $("#resultcompany1").show(); $("#resultcompany2").show(); $("#errorsearch").hide(); }, success: function(data){ $(".insid_body_web").html(data); $('html, body').animate({scrolltop:$('#insid_body_web').offset().top}, 'slow'); $("#resultcompany1").show(); $("#resultcompany2").show(); $("#errorsearch").hide(); $(".insid_body_web").css("min-height","1397px"); }, error: function() { $("#errorsearch").show(); $("#resultcompany1").hide(); $("#resultcompany2").hide(); }, }); }
and php function result:
public function selectallcompanydatabypagingbycat($char,$company,$cat,$country,$from,$records) { $sql ="select company_compname,company_phone,company_site,company_id company company_delete ='0' , company_request = '0' "; if ($cat !=""){ $sql .= " , company_compcat = '".$cat."' "; } if ($company !=""){ $sql .= " , company_compname = '".$company."' "; } if ($country !=""){ $sql .= " , company_country = '".$country."' "; } if ($char !=""){ $sql .= " , company_compname '".$char."%' "; } $sql .= " order company_id desc limit $from,$records"; $query = @mysql_query($sql); return $query; mysql_free_result($query); }
chage data in ajax this
data: { "mysearchchar" : char, "mysearchcompany" : company, "mysearchcategory" : category, "mysearchcountry": country, "mypage" : page },
and in companyresult.php
$cat = trim($_post['mysearchcategory']); $company = trim($_post['mysearchcompany']); $country = trim($_post['mysearchcountry']);
...... , on...
Comments
Post a Comment