Tuesday, 6 August 2013

Explain function

Explain function

Hai i have this script in my project . its working fine. I would like to
know what is the alternate for typahead in my second function.first one is
auto complete. send one is just check the username is available in
database or not. I know the second one is working fine but not correct
method. please suggest me what is the correct method
<input type="text" name="place" id="place" placeholder="Place"
data-provider="typeahead" class="validate[required,maxSize[100]]"/>
<input type="text" name="emailid" id="emailid" data-provider="typeahead"
placeholder="Email Id"
class="validate[required,maxSize[150],custom[email]]"/>
<script type="text/javascript">
$(function(){
$('#place').typeahead({
source: function(query,process){
$.ajax({
url:'search/place.php',
type:'POST',
data:'query='+ query,
dataType:"JSON",
async:true,
success: function(data){
//console.log(data);
process(data);
}
});
}
});
//-------------------- email id registred or not check--------------
$('#emailid').typeahead({
source: function(query,process){
$.ajax({
url:'search/user.php',
type:'POST',
data:'query='+ query,
dataType:"JSON",
async:true,
success: function(data){
if(data==0){
$("#message").html("<img
src='bootstrap/jq/tick.png' /> ");
}
else
{
$("#message").html("<img
src='bootstrap/jq/cross.png' /> ");
}
}
});
}
});
//-----------------------------------------------------------------------------------------
});
</script>

No comments:

Post a Comment