I am new to ajax jquey in programming.I had successfully inserted values which i posted via form field(id,name,age) in my xml file.But i am not printing the correct result in my HTML table.I had to insert the datas in xml file and also display the result in an HTML table.
My ajax jquery code is as follows:
$(document).ready(function() {
$("#myTable").tablesorter( {sortList: [[0,0], [1,0]]} );
$("#login").click(function() {
var action = $("#form1").attr('action');
var form_data = {
id: $("#id").val(),
name: $("#name").val(),
age: $("#age").val(),
is_ajax: 1
};
$.ajax({
type: "POST",
url: "x1.php",
data: form_data,
success: function(response)
{
if(response == 'success')
$("#form1").slideUp('slow', function() {
$("#message").html("
Details are entered into the table!
");
});
else
$("#message").html("
Please enter details
");
$("#message").show();
}
});
return false;
});
});
MY HTML table code is as follows:
id
name
age
<?php
foreach($xml as $xmls)
{
?>
<?php echo "".$xmls->id."";?>
<?php echo "".$xmls->name."";?>
<?php echo "".$xmls->age."";?>
<?php
}
?>
</div>
my XML file contains data result as:
<?xml version="1.0"?>
<Order>
<title>
<id>1</id>
<name>baven</name>
<age>45</age>
</title>
<title><id>2</id><name>simi</name><age>22</age></title><title><id>3</id><name>great</name><age>34</age></title></Order>
i would like to output the result in a table as:
id name age
1 baven 45
2 simi 22
3 great 34
I need to get the result not by refreshing the page but by clicking the submit button.Any help would be appreciated..