![]() |
Using jquery validation plugin to check username availability - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived Libraries & Helpers (https://forum.codeigniter.com/forumdisplay.php?fid=22) +--- Thread: Using jquery validation plugin to check username availability (/showthread.php?tid=43274) |
Using jquery validation plugin to check username availability - El Forum - 07-06-2011 [eluser]sanks[/eluser] Hi, I am facing problems while using jquery validation plugin using codeigniter. The remote method does not process the request. My code for js is as follows: Code: $(document).ready(function(){ And the code for controller is: Code: <?php if ( ! defined('BASEPATH')) exit('No direct script access allowed'); Code: function check_availability() Using jquery validation plugin to check username availability - El Forum - 07-06-2011 [eluser]Flyingbeaver[/eluser] Can you try to use firebug or any development tool, to watch the ajax call see where it goes and what it returns in content/error ? Using jquery validation plugin to check username availability - El Forum - 07-07-2011 [eluser]sanks[/eluser] nothing is diplayed. what do you expect when using remote method? Using jquery validation plugin to check username availability - El Forum - 07-07-2011 [eluser]Flyingbeaver[/eluser] You are trying to access : url: 'user/check', type: 'post'. 1. You should this this in tour xhr tab 2. If you see this, you should look if there is an error 3. If there is no error you should look what is returned Using jquery validation plugin to check username availability - El Forum - 07-07-2011 [eluser]sanks[/eluser] How can I check what is returned? Can you please elaborate by writing sample code? Using jquery validation plugin to check username availability - El Forum - 07-07-2011 [eluser]Flyingbeaver[/eluser] It's not about code it's about debugging. You should learn to use firebug it's a must have tool for web developpers. Using jquery validation plugin to check username availability - El Forum - 07-07-2011 [eluser]sanks[/eluser] It gives 404 not found error. Sorry but I fixed it. then too the username is not validated and the reponse is nothing Using jquery validation plugin to check username availability - El Forum - 07-07-2011 [eluser]sanks[/eluser] I got the response as true or false. but its not displayed on the screen. Also the problem here is that my data is being validated only once. Using jquery validation plugin to check username availability - El Forum - 07-07-2011 [eluser]sanks[/eluser] I fixed it. Instead of returning the value in check() function of ajax controller I used to echo the value to true or false. Also I used $valid as variable to echo it. So the new code is as follows: Code: <?php if ( ! defined('BASEPATH')) exit('No direct script access allowed'); I guess the jquery validate plugin seeks the value of $valid variable. I hope this post is useful to someone as I always found imperfect answers on this topic Using jquery validation plugin to check username availability - El Forum - 07-07-2011 [eluser]Irfan Cikoglu[/eluser] Don't use return true; use echo 'true'; |