I am new to working with AJAX, and I have been trying to use it for a POST function similar to the curl command below:
curl -X POST -H 'Content-type:application/json' --data-binary '{
"replace-field":{
"name":"sell-by",
"type":"date",
"stored":false }
}' http://localhost:8983/solr/gettingstarted/schema
Based on available resources in SF, I created the function below. However, the data is not being posted to the app, and there are no console errors.
function sendData() {
$.ajax({
url: 'http://localhost:8983/solr/techproducts/schema',
headers: {
"Access-Control-Allow-Origin":"*"
},
type: 'POST',
contentType: 'application/json',
data: JSON.stringify({
"replace-field":{
"name":"sell-by",
"type":"date",
"stored":false
}
}),
success: function (response, status, xhr) {
if (status == "success") {
alert("sucess");
} else {
alert(status + ' - ' + xhr.status);
}
},
// processData: false, // this is optional
dataType: 'jsonp',
jsonp: 'json.wrf',
crossDomain: true,
});
}