javascript - JQuery is not detecting my DOM Object when clicked -
this question has reply here:
why jquery or dom method such getelementbyid not find element? 6 answershaving bit of problem figuring out going wrong here , wondered if might able help me out. i'm using jquery
throughout site reason on particular page not seem working.
this code here:
$("#keyword").autocomplete({ source:'../../pages/ajax/autocomplete/autocomplete_tags.php', datatype: 'json', minlength:1 }); //when nail search button load new tags $("#srchbtn").click(function(e){ e.preventdefault(); var tag_name = $('#keyword').val(); $(".dashboardtable").load('../../pages/ajax/autocomplete/search_tags.php', {tag_name: tag_name },function(response, status, xhr){ $(".dashboardtable").html(response); $("#keyword").val(""); $("#keyword").attr("placeholder", "search tags..."); }); });
what should happen when user begins typing begins pulling suggestions out of database , when click search button loads results div using ajax
. noticed wasn't working , decided i'd seek simple test:
$('#srchbtn').click(function(){ console.log('hit'); })
but nil appeared in console. tried
console.log($('#srchbtn'));
, seem getting reference dom object, isn't firing click event reason.
i've got next scripts
@ top of page:
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script> <script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.11.0/jquery-ui.min.js"></script> <script src="../scripts/auto-complete/tag_list_search.js"></script>
and getting no errors in console. perchance problem? help much appreciated. html
:
<input type="text" id="keyword" placeholder="search tags..." size="33"/> <input type="button" class="" id="srchbtn" value="search"/>
please wrap code in jquery ready function...(in case not done) $(function(){ // jquery ready function $("#keyword").autocomplete({ source:'../../pages/ajax/autocomplete/autocomplete_tags.php', datatype: 'json', minlength:1 }); //when nail search button load new tags $("#srchbtn").click(function(e){ e.preventdefault(); var tag_name = $('#keyword').val(); $(".dashboardtable").load('../../pages/ajax/autocomplete/search_tags.php', {tag_name: tag_name },function(response, status, xhr){ $(".dashboardtable").html(response); $("#keyword").val(""); $("#keyword").attr("placeholder", "search tags..."); }); }); });
javascript jquery ajax
No comments:
Post a Comment