Event not working
Event not working
I am having a problem with some code that I am working on. The code is shown below. Basically, I have a page that if you click on one of the links, it uses the .load method to pull in a php document. The php document displays a form (since nothing has been submitted to it yet) that has an input box and a button to launch a search. I attach a click event to the button, however, when I click it, nothing happens. I monitored the script in Firebug, and it appears that the event handler does get attached as it goes to that method following the AJAX callback, but then when you click it, no server request is ever made. Could someone please help a rookie out and let me know what I am doing wrong. I greatly appreciate the assistance.
- <script type = "text/javascript">
-
- $(document).ready(function() {
-
- $('#allServers').click(function() {
- $('#content').load('maintInfoAll.php');
- });
- $('#byName').click(function() {
- $('#content').load('maintInfoName.php', addClickHandlers());
- });
-
- $('#byDay').click(function() {
- $('#content').load('maintInfoDay.html');
- });
-
- });
-
- // end of doc ready function
-
- function addClickHandlers() {
-
- $('#searchButton').click(function() {
-
- $.post('maintInfoName.php', $('#serverNameForm').serialize(), function(data) {
-
- $('#content').html(data);
-
- });
-
- });
-
- };
-
- </script>