I'm new with AJAX so probably I'm missing something. I'm finding a problem (Error 500 Internal server) while updating a mysql table through an external php source.
Basically I'm trying to do the following:
click on button > call ajax function > call php > update mysql table.
I'm working with wordpress and MAMP.
Here is my code.
1. Button
<button onclick="unreadMessage()" class="messages btn btn-menu dropdown-toggle" data-toggle="dropdown" type="button">
2. jQuery / AJAX function
function unreadMessage(){
$.ajax({
type: "POST",
url: "<?php bloginfo('template_url'); ?>/lib/unread.php",
data: { 'read': '1' },
success:function() {
alert("ok");
}
});
}
3. My external file code unread.php
global $current_user, $wpdb, $wp_query;
get_currentuserinfo();
$uid = $current_user->ID;
$read = $_POST['read'];
$sql = "update ".$wpdb->prefix."project_pm set rd='$read' where id='{$row->id}' AND user='$uid' and notify='1'";
if(mysqli_query($sql)){
}
else {
return "failed!";
}
Thank you in advance for your time!