Reputation: 1172
I've a long list of items in a select box (more or less 6000). When I load the PHP page, it takes a while. Because of the fact, that this <select>
is very rarely chanced, I would like to load the <option>
´s just in case, that I need them.
I would call the jquery function
$("#select_id").load("code.php").change();
But which handler should I use? And how can I shot the user, that this is loading for 1-2 sec.?
Upvotes: 0
Views: 531
Reputation: 73896
Try this:
var $select = $('#select_id');
$select.load('code.php', function () {
$select.change(function() {
alert('Handler for .change() called.');
});
});
We have used the Callback Function here. So, the code select.change()
will be executed after post-processing and HTML insertion has been performed.
Upvotes: 1