I am trying to insert input values into database with the help of form without refreshing the page.For this my form is

<title>Jquery test</title>
<script src="http://code.jquery.com/jquery-latest.js"></script>
$('insert').click(function() {

    $.post("test2.php", $(this).closest("form").serialize());
<form id="test">
<td>First Name</td>
<td><input type="text" name="fname"></td>
<td>Last Name</td>
<td><input type="text" name="lname"></td>
<td colspan="2"><input type="button" name="insert" value="insert"></td>

And my test2.php file is-

$sql="INSERT INTO user (first_name,last_name) VALUES ('".$_POST['fname']."','".$_POST['lname']."')";

but this is not working for me.Please help me.Thank you in advance.

Add an or die(mysql_error()) to your query to see if it's failing. It's a very bad idea to add un-verified data to your DB. At the absolute very least you should make sure your POST data is set. Without any form of error handling it's difficult to say where exactly this is failing.