I have problem with ajax and php.I have next code
$("form").submit(function() {
var poruka = $("#poruka").val();
$.ajax({
type: "GET",
url: "/ajax/gather/send/"+ poruka + "/'.$id.'",
success: function(){
loaduj('.$id.');
alert("Your message is "+poruka);
},
error: function(){
alert("fail");
}
});
});
"poruka" is the message and it's taken from form
<form action='javascript:;'>
<input type='text' name='poruka' id='poruka' placeholder='Poruka..' style='width:100%;'>
<input type='button' name='button' hidden>
</form>
And when i try to send to php it won't insert that into database :
Php code :
$text = $_POST['text'];
$id = $_POST['id'];
if($text != ""){
mysql_query("INSERT INTO messages (text,id2) VALUES ('$text','$id')") or die(mysql_error());
}
And it can't work..How can i fix it ? Thanks