Monday, March 30, 2015

Ajax request , response using jQuery

Ajax request , response using jQuery


<a onclick="callController();" href="javascript:void(0)">View More Articles</a>

<script type="text/javascript">
function callController(){
    
       new Ajax.Request("REQUEST FILE PATH HERE", {
           method: 'Post',
           parameters: {"pg_num":"<?php echo '1';?>"},
           onComplete: function(transport) {
            alert(transport.responseText);
           }
       });
   }
</script>

Thursday, March 26, 2015

jQuery:Tab Hide show

<ul class="tab-cat-name">
    <li>
        <a class="" href="javascript:void(0)" onclick="ShowHideTab('1')">Tab1</a>
        <a href="javascript:void(0)" onclick="ShowHideTab('2')" class="active">Tab2</a>
    </li>
</ul>
<div id="show_hide_1" class="tab-listing" style="display: none;">           
Content1
</div>
<div style="" id="show_hide_2" class="tab-listing">
Content2
</div>
       
<script type="text/javascript">
function ShowHideTab(current){
    jQuery( ".tab-listing" ).each(function( index ) {
        var toshow= index+1;
            if(current==toshow){
            jQuery('#show_hide_'+toshow).fadeIn(1000);
            }else{
            jQuery('#show_hide_'+toshow).fadeOut(1000);
            }
 });
}  
</script>

Wednesday, March 11, 2015

PHP-Load other page / landing page on first time url hit

Load other page / landing page on first time url hit



$ref_url = $_SERVER['HTTP_REFERER'];
$actual_link = "http://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]";

if ($ref_url == '' && $actual_link  == 'http://your-site/') {  
    header('Location:http://your-site/landingpage.html');
    exit;
}


Njoy  :) :)