The following script returns a failure, even though it used to work:
function postToPHP(data_to_send) {
$.ajax({
type: "POST",
datatype: "json",
async: false,
url: "http://school.edu/myurl/write_to_mongo.php",
data: data_to_send,
success: function ($msg) {
alert('success');
return;
},
error: function () {
alert('failure to send to database');
}
});
In case it matters, it interacts with the following PHP script:
//Get data from .ajax call
$data = $_POST;
//Open mongo and select database
$m = new Mongo();
$db = $m->selectDB("numbers");
//select a collection
$collection = $db->testData;
//insert data
$collection->insert($data);
//find collection contents
$cursor = $collection->find();
echo $data;
?>
Any idea what's gone wrong? My Safari debugger is showing me "failure to load resource. There was a bad response from server.", but hunting this down on Google isn't producing anything useful; I've already made sure I'm importing jQuery properly.