Skip to content

Latest commit

 

History

History
91 lines (77 loc) · 1.76 KB

README.textile

File metadata and controls

91 lines (77 loc) · 1.76 KB

jQuery SerializeTable documentation

What it does

jQuery SerializeTable is a jquery plugin that get data from a table when clicked. And make into JSON all data, and can be read by PHP and return to fields or to any page by AJAX. View example

How to use it


<script src="jquery.js"></script>
<script src="jquery.serializetable.js"></script>
<script>
$(document).ready(function() {
	$('#your_table').serializeTable({
		'file': 'path/to/file.php',
		'params': 'parameter_name',
		'data': '#element'
	});
});
</script>

Options

  • file: Name of AJAX file. Defaults to empty.
  • params: Name of parameter to request. Defaults to params.
  • data: Element, ID or Class to return AJAX data. Defaults to #content.
  • attr: Attribute that contains the field name. Defaults to rel.
  • loading_text: Text displayed on loading. Defaults to empty.
  • loading_class: Class to personalize loading. Defaults to serializetable-ldg.

Complete Example

Plugin


<script>
$(document).ready(function() {
	$("#my_table").serializeTable({
		"file": "ajax.php",
		"params": "juice",
		"data": "#return"
	});
});
</script>

HTML


<table>
	<thead>
		<tr>
			<th>Name</th>
			<th>Color</th>
		</tr>
	</thead>
	<tbody>
		<tr>
			<td rel="name">Heberti</td>
			<td rel="color">Blue</td>
		</tr>
		<tr>
			<td rel="name">Luis</td>
			<td rel="color">Green</td>
		</tr>
	</tbody>
</table>
<div id="return"></div>

PHP AJAX


<?php
	$json = $_REQUEST["juice"];
	$obj = json_decode($json);
?>	

<!-- Sample -->
<input type="text" value="<?php echo $obj[0]->name?>" />
<input type="text" value="<?php echo $obj[0]->color?>" />