I am trying to make an ajax veryfication but i do not know why it doesn't work.
This is my ajax script:
<script type="text/javascript" language = "javascript">
function checkWords () {
var status = document.getElementById("status");
var u = document.getElementById("styled").value;
if(u != "")
{
status.innerHTML = 'Verifying...';
var hr = new XMLHttpRequest();
hr.open("POST","/topicnou",true);
hr.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
hr.onreadystatechange = function(){
if (hr.readyState == 4 && hr.status == 200)
{status.innerHTML = hr.responseText;}
}
var v = "name="+u;
hr.send(v);
}
}
</script>
This is my php :
<?php
if(isset($_POST['name']) && $_POST['name'] != ""){
echo 'succes';
}
?>
PS: bought scripts are located in TopicNou.blade.php wich is seen if you go to localhost/topicnou.
This is what appears in my console:
POST http://localhost/topicnou 500 (Internal Server Error)
XHR finished loading: POST "http://localhost/topicnou".