Passing variables using jquery and ajax php -
i'm following tutorial, issue is: have code here, tables.
<tr id="<?php echo $id; ?>" class="edit_tr"> <td class="edit_td"> <span id="first_<?php echo $id; ?>" class="text"><?php echo $kodi; ?></span> <input type="text" value="<?php echo $kodi; ?>" class="editbox" id="first_input_<?php echo $id; ?>" /> </td> <td class="edit_td"> <span id="last_<?php echo $id; ?>" class="text"><?php echo $vlera; ?></span> <input type="text" value="<?php echo $vlera; ?>" class="editbox" id="last_input_<?php echo $id; ?>"/> </td> </tr> now, script:
<script type="text/javascript"> $(document).ready(function() { $(".edit_tr").click(function() { var id=$(this).attr('id'); $("#first_"+id).hide(); $("#last_"+id).hide(); $("#first_input_"+id).show(); $("#last_input_"+id).show(); }).change(function() { var id=$(this).attr('id'); var kodi=$("#first_input_"+id).val(); var vlera=$("#last_input_"+id).val(); var datastring = 'id='+ id +'&kodi='+kodi+'&vlera='+vlera; $("#first_"+id).html('<img src="load.gif" />'); // loading image if(first.length>0&& last.length>0) { $.ajax({ type: "post", url: "table_edit_ajax.php", data: datastring, cache: false, success: function(html) { $("#first_"+id).html(first); $("#last_"+id).html(last); i'm not passing variables right maybe..because won't save them, query won't excecute. thanks
the easiest way in jquery pass form fields in ajax using serialize:
data: $("form").serialize(); an additional problem using 2 variables, first , last not defining them anywhere.
Comments
Post a Comment