I have a following code:
INPUT
<div class="row">
<div class="form-group">
<div class="col-sm-3">
<div class="form-group input-group">
<input id="contact-input" type="text" id="search" class="form-control input-search-doc" placeholder="Documento" required>
<span class="input-group-btn">
<button class="btn btn-default btn-search-doc" type="button">
<i class="fa fa-search"></i>
</button>
</span>
</div>
</div><!-- <div class="col-sm-3"> -->
</div><!-- <div class="form-group"> -->
</div><!-- <div class="row"> -->
AJAX
$(".btn-search-doc").on("click",function(){
var title = $(this).find('input.input-search-doc').val();
alert(title);
$("#result").html("<img src='ajax-loader.gif'/>");
$.ajax({
type:"post",
url:"../connect/post/select.php",
data:"title="+title,
success:function(data){
$("#result").html(data);
$("#search").val("");
}
});
});
It should get the text inside the input and send via Ajax to my select, but it can not get the text inside the input "input-search-doc" , always returns it to me in var_dump : string 'undefined' (length = 9)
Does anyone have an idea why it is not taking any value?