我还没有参与过AJAX,我曾尝试过ajax函数在curl下面发布这个,
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
我已根据SF中可用的资源编写了以下功能,但这并未将数据发布到应用程序。它也不会抛出任何控制台错误。
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,
});
}
答案 0 :(得分:0)
function sendData() {
$.ajax({
url: 'http://localhost:8983/solr/techproducts/schema',
headers: {
"Access-Control-Allow-Origin":"*"
},
type: 'POST',
contentType: 'application/json',
data: {
"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,
});
}