i wan't to run a jquery but when i run it i first get my value and then the code failed error. What does this mean? Here you can find my json en ajax file. It seems that the json won't go to my ajax file.
$("#submit_tosolve").on("click",function(e){
//data uitlezen
alert("ok");
var message =$("#bugcommentaar").val();
console.log(message);
alert("ok");
//data naar database sturen
var request = $.ajax({
url: "ajax/facebook_ajax.php",
type: "POST",
data: {message : message}, //JSON
dataType: "json"
});
request.done(function(msg) {
if(msg.status=="success"){
var update='<div style="display:none;" class="span4">'+
' <table><tr><td><h5><p>'+ message+'comment posted </p></h5></td></tr></table></div>';
$("#singleBug table").prepend(update);
$("#singleBug table tr td").first().slideDown(); //dit gaat werken op elke browser, de eerste eruit halen
}
});
request.fail(function(jqXHR, textStatus) {
console.log("request failed" +textStatus);
});
});
my ajax file :
<?php
include_once("../classes/Bug.class.php");
$feedback=array();
if(isset($_POST['message']))
{
try
{
$Bug = new Bug();
$Bug->Commentaar=$_POST['message'];
$Bug->Bug_id=$_SESSION['id2sessioncommentaar'];
$Bug->UpdateCommentaar();
$feedback['text'] = "Your comment has been posted!";
$feedback['status'] = "success";
}
catch(Exception $e)
{
$feedback['text'] = $e->getMessage();
$feedback['status'] = "error";
}
header('Content-Type: application/json' );
echo json_encode($feedback);
}
?>