Global variable not setting
Hi,
Here is a snippet of my code, not complete, but shows the areas in question. I have defined var id on before anything this gets defined then set it on line 5 ... it's the table's row ID. I want to access this in line 17 but it says undefined, I just can't think why any clues?
- $(document).ready(function() {
- var id;
- $('.comment').click(function() {
- $('#dialog').dialog('open');
- id = $(this).closest('tr[id]').attr('id');
-
- });
- $('#submitcomment').click(function() {
- var dataString = $('textarea#comment').val();
- $.ajax({
- type: "POST",
- url: "showrota.php",
- data: { message: dataString},
- success: function() {
- $('#dialog').dialog('close');
- showMessage('#53FF38', 'black', 'Comment Added' + id );
- }
- });
- return false;
- });
Thanks