am using jquery to bind an event to a text input. The event simply performs an ajax call.
Problem is my code works fine in Firefox, but the event is never triggered in IE6. Heres my code:
</script type="text/javascript" src="/js/jquery/jquery.js"></script>
<script type="text/javascript">
// Turn off caching for Ajax
$.ajaxSetup({
cache: false
});
var ajaxCallURL = "http://<?php echo $_SERVER['HTTP_HOST']; ?>/check";
$(document).ready(function() {
$("#test").change(function() {
alert("Event fired");
$('#result').load(ajaxCallURL,null, function(responseText) {
alert("Ajax call successful");
});
});
});
</script>
<input style="WIDTH: 30em" id="test" name="test" value="" type="text"/>
<div id="result"></div>
After typing in the text box, both alerts are shown in Firefox, but nothing in IE6.
I also should say that the element is being created using Zend_Dojo clas开发者_运维问答ses, but i cant see an issue with using Dojo and jQuery as its works fine in Firefox.
Am thinking it must be that the event is never bound to the element in IE due to maybe Dojo is not fully loaded in IE when $(document).ready is called....
Any ideas anyone??
Many thanks
The change
event isn't fired here in some browsers until you click outside and cause a blur to happen.
If you want to fire on every keypress, I would use .keyup()
instead of .change()
. But this may fire too often to run an AJAX call all the time, so you may want to add a timer in there. See this answer for an example of how to do that.
精彩评论