Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
  • Active and inactive users concept using Ajax in Cakephp

    • 0
    • 1
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 2.70k
    Comment on it

    Concept of active,inactive script is mostly used in Online shopping website, Where adminstrator has right to access the database table and can be able to do changes on the table according to his need. For example a site owner wants to hide some of its product and want to access to check the availability of product, and the status of the product which is going to be sold out in few days.Here is simple line of code of Ajax by which the data is passed in the string form and will display the table of active users whose status is 1 and also the inactive users whose status is 0.

    Ajax Code:

    <script src=""></script>
    <script type="text/javascript">
    		function fetchdata(data){
    		       	// console.log();
    		       error:function(XHR, textStatus, errorThrown )
    		       	// alert(textStatus);
    <a href="#" id="active">active user</a>
    <a href="#" id="inactive">inactive user</a>
    <?php //echo $this->Html->link('active',array('onclick'=>'fetchdata();'));?>
    <?php //echo $this->Html->link('in-active',array('onclick'=>'fetchdata();'));?>
    <div id="table"></div>


    echo "<table>
    	foreach($result as $value)
    	echo "<tr><td>".$value['User']['name']."</td><td>".$value['User']['address']."</td>
    echo "</table>";

    Controller code:

    public function fetch($data=null)
          	$result=$this->User->find('all', array('conditions'=>array('User.status'=>$data)));



 0 Comment(s)

Sign In

Sign up using

Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: