javascript - Why the AJAX function is not getting called and alert is not getting printed upon calling the function? -
i want call ajax function once user clicks on select control or select control gets focus keyboard.
html code follows :
<select id="scanner" name="scanner" class="form-control"></select> the jquery-ajax function wrote follows aler("hello") not getting printed. why so?
 $("#scanner").bind("change",function() { alert("hello");      var mod_url = $('#mod_url').val();       $.ajax({       url : mod_url,       cache: false,       datatype: "json",       type: "get",       async: false,       data: {         'request_type':'ajax',          'op':'get_all_stores'       },       success: function(result, success) { alert(result);         $('#scanner').html(result);       },       error: function() {         alert("error occured");       }     });   }); 
in code haven't seen options html select box
and, have registered change event on select box occur on selecting options in select box
add few options in select box , try select options fire ajax call
see js fiddle here
Comments
Post a Comment