Skip to content

jQuery SerializeTable is a jquery plugin that get data from table when click in row. And make into JSON all data, and can be read by PHP and return to input or to any element by AJAX.

Notifications You must be signed in to change notification settings

ls-rajan-rauniyar/Serialize-Table

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

28 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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?>" />

About

jQuery SerializeTable is a jquery plugin that get data from table when click in row. And make into JSON all data, and can be read by PHP and return to input or to any element by AJAX.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published