I am trying to fire a XMLHttpRequest
to mongoDB to retrieve a document via AJAX.
This is my code:
function getJsonDocumentByModeldid(model_id) {
var valoreInput = document.getElementById('inputModelId').value;
alert(valoreInput);
$.ajax({
url: "http://localhost:28017/test/",
type: "get",
//data: "filter_a=" + valoreInput,
dataType: 'jsonp',
crossDomain: true,
success: function (data) {
alert("success");
//var json2javascript = $.parseJSON(data);
manageLayout();
},
error: function (XMLHttpRequest, textStatus, errorThrown) {
alert("Status: " + textStatus + " Error:" + errorThrown);
}
});
}
My function always returns an error. So what is the problem?