its ajax code:
$("#adata").click(function()
{var tmp;
tmp = "12354";
$.ajax({
type: "POST",
url: "some_page.php",
data: "insertdate:insertdate,exercise_ID:exercise_ID,userID:userID,exctype:exctype",
dataType:"html",
async: false,
success: function(data)
{
$('#datepickers').html(data);
}
});
});
});
This is the php file:some_page.php:
$conn=mysql_connect("localhost","root","");
mysql_select_db("fit2startdemo");
$query=mysql_query("select * from jos_fitness_info where insertdate = '$insertdate'");
if (mysqli_num_rows > 0)
{
echo "0"; //date exists
}
else
{
echo "1"; //date not exists
}
$('#adata').click(function() {
var tmp;
tmp = "12345";
$.ajax({
type:"POST",
url: "some_page.php",
data: {insertdate:insertdate,exercise_ID:exercise_ID,userID:userID,exctype:exctype}
}).done(function( msg ) {
alert(msg);
$('#datepickers').html( msg );
});
});
Try that
EDIT: so in your php code if the date matches then echo 'This Date already exists in Databse' and don't insert, else insert it
EDIT:
The problem was firstly that you were trying to send post data to, and retrieve a response from a php page that didn't exist. So first port of call when the callback function in an ajax request isn't working is whether or not it's actually communicating with the file (as if it's not the .done() function is never used as it's not successful.