I'm currently working on a project which requires some AJAX, but for some reason my current code wont send the POST data. here is my AJAX:
<script>
$('#greenon').click(function(){
$.ajax({
type: 'POST',
url: 'command.php',
data : { "green" : "on" },
success: function(data, textStatus, jqXHR) {
alert("it worked!");
},
error: function(jqXHR, textStatus, errorThrown) {
alert("didn't work!");
}
});
return false;
});
</script>
And it's not even sending the 'didnt work' alert. I am using this in command.php (it would write the file if command.php got accessed,
<?php
$content = "bleh";
$fp = fopen($_SERVER['DOCUMENT_ROOT'] . "/file.txt","wb");
fwrite($fp,$content);
fclose($fp);
?>
Why is it not sending POST data? thanks!
oh and here is my button HTML:
<a class="btn btn-success" role="button" id="greenon">Turn On</a>