On my view page if I am entering username after loader.gif is loading but I am getting the result for username available or not.. pls give me any ideas...
This is my controller:
public function name()
{
$username = Input::get('username');
$users = DB::table('user')
->where('username', 'LIKE', '%'.$username.'%')
->get();
if (count($users) < 0)
{
return view('test/username');
}
else
{
return view('test/username');
}
}
These are my routes:
Route::post('test/username', 'PageController@name');
This is my Blade template:
<html>
<head>
<script type="text/javascript" src="http://ift.tt/1mxYZHA"></script>
<script type="text/javascript">
$(document).ready(function () {
$("#username").change(function () {
$("#message").html("<img src='../images/loader.gif' /> checking...");
var username=$("#username").val();
$.ajax({
type:"post",
dataType: "json",
url: "{{ URL::to('test/name') }}",
data: "username=" + username,
success: function (data) {
if (data == 0) {
$("#message").html("<img src='../images/yes.png' /> Username available");
} else {
$("#message").html("<img src='cross.png' /> Username already taken");
}
}
});
});
});
</script>
</head>
<body>
<table>
<tr>
<td>Username</td>
<td>:</td>
<td>
<input type="text" name="username" id="username"/>
</td>
<td id="message"></td>
</tr>
</table>
</body>
</html>
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire