Reputation: 36411
In this function, when I use it I get error on the whole code block! (in chrome console)
however when I replace live
with click
it works fine, how is it?
$("form[0] :submit").live(function(event) {
event.preventDefault();
var search_data = { company : $("form[0] :text").val() }
$.ajax({
type: "POST",
url: "<?= site_url('pages/search') ?>",
data: search_data,
success: function(msg){
alert( "Data Saved: " + msg );
}
});
});
Upvotes: 1
Views: 291
Reputation: 17598
When you use .live()
, you have to specify which kind of event you want to bind a handler for. For most situations, it looks like this:
$('form[0]').live('submit', function() {
...
});
You can also use a space-separated list of event types, or an object with event type : function pairs for multiple events / functions.
Upvotes: 1