Here is my Jquery and Php file, in which i will post the values in php file through jquery,
In Simple :
<script type="text/javascript" src="../jquery.min.js"></script>
<script type="text/javascript" language="javascript">
$(document).ready(function() {
$("#driver").click(function(event){
var name=$("#txt").val();
$.post("test_post.php",
{name: name}).done(function(data){
$('#stage').html(data);
}
);
});
});
</script>
</head>
<body>
<input type="text" id="txt" value="Load Data" />
<input type="button" id="driver" value="Load Data" />
</body>
Here is the .php file. If the insert was success i should get alert as success else i should get alert as failure.
<?php
include ('conn.php');
if( $_REQUEST["name"] )
{
$q = "INSERT INTO text (name) VALUES ($name)";
if(mysql_query($q))
{
echo 'success'.$q;
}
else
{
echo 'fail'.$q;
}
}
?>
And the echo should be displayed in the main page.
How can i do this ?