Who do I get jquery to show the new value of a variable
Jquery noob here. I have a table in which each row has a View button. I store the variable that holds the record's id in a data-whatever tag
- <button><a id="buttone" type="submit" class="btn btn-small" data-whatever="<?php echo $eventID ;?>">View</a></button>
I have a div that i want to load details of the selected record for, beneath the table. When I click the button I pass the id to a php page that displays in the div on the same page.
The problem is jquery is only storing the variabe for the first record in the table so i can only load the details of the first record no matter which one i click. I have searched but I am not exactly sure whats applicable in my case, below is what I have tried. Thanks for your help.
- $(document).ready(function(){
- $('#form').submit(function(){
- $('#insertResult').empty();
-
- //var id = null;
- //$ ("#buttone").removeAttr('data-whatever');
- //$("#buttone").removeData('whatever');
- //var id = $( "#buttone" ).attr('data-whatever');
- //var id = $("#eventID").val();
- var dataString = "id=" + id
-
- $.ajax({
- type: "GET",
- url: "readnote.php",
- data: dataString,
- cache: false,
- success: function (data) {
-
- $('#insertResult').html(data);
- },
- error: function(err) {
- console.log(err);
- }
- });
- return false;
- });
-
- });