Jump to content

[SOLVED] Kohana framework with JQuery issue


Recommended Posts

Hi all,


I'm new to Kohana and JQuery but I think my problem should be easy to fix.


What I want to do is dynamically check the database for usernames as soon as a user starts inputting a character, so I'm using the JQuery method .keyup for that.  The data is getting passed to the javascript as I can pass it to the alert() function and it is displayed as I expect it.  However the data doesn't appear on the webpage as I type it, its only printed on the page when the submit button is clicked.  I want it to display when it is submitted and on keyup.


Any ideas?


Here's the "view":

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">   

  	 <script src="/application/views/jquery-1.3.2.min.js" type="text/javascript" charset="utf-8"></script>
<script type="text/javascript" src="/application/views/jquery.form.js"></script> 
    <script type="text/javascript" charset="utf-8">

        function sendValue(str){
	//	alert('sending value: '+str);
         //   $.post("/index.php/user/create.php",{ sendValue: str },
	   $.post("/application/controllers/user.php",{ sendValue: str },
		//$.post("create.php",{ sendValue: str },
            }, "json");
     echo html::stylesheet(array  
     ), FALSE);   
<?php echo form::open('user/create'); ?>   

<table class='editor'>   
     <td colspan='2' class='editor_title'>Register</td>   
     echo "<tr>";   
	echo "<td>".form::label('username', 'Username: ')."</td>";   
	//echo "<td>".form::input('username', '')."</td>";   
	echo '<td><input type="text" name="username" id="username" /></td>';
	echo "<td> <div id=\"username\"></div></td>";
     echo "</tr>";   
     echo "<tr>";   
     echo "<td colspan='2' align='left'>".form::submit('submit', 'Register')."</td>";   
     echo "</tr>";   
<?php echo form::close(); ?>   


Here's the "controller":


<?php defined('SYSPATH') OR die('No direct access allowed.');   
class User_Controller extends Controller   
     private $user_model;    
     private $createuser_view;   
    public function __construct()      
        $this->user_model   = new User_Model;   
        $this->createuser_view   = new View('createuser');   
   public function index()   

    public function create(){    
		'username'  => $this->input->post('username')   

	$db_users_list  = $this->user_model->findByUsername($user_data['username']);    
        if(sizeof($db_users_list) == 0){   
		echo json_encode(array("returnValue"=>"This is returned from PHP : ".$user_data['username'])); 
        }elseif(sizeof($db_users_list) == 1){


Link to post
Share on other sites



Would replace the entire form element with your value, you need to use the val() method. eg;




Also, I'm not a kohuna user, but it looks to me like your uri ought to be....




And within that method you should be looking for your data within...


'username'  => $this->input->post('sendValue')

Link to post
Share on other sites


This topic is now archived and is closed to further replies.

  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.