0
我正在使用phonegap應用程序。我想將數據映像發送到服務器,但我無法發送它。Ajax將圖像發送到服務器
function addSiteToServer() {
var cId = localStorage.getItem("cId");
var sname = $('#sitename').val();
var slat = $('#lat').val();
var slng = $('#lng').val();
var storedFieldId = JSON.parse(localStorage["field_id_arr"]);
var p = {};
for (var i = 0; i < storedFieldId.length; i++) {
var each_field = storedFieldId[i];
var val_each_field = $('#' + each_field).val();
p[each_field] = val_each_field;
console.log("p" + p);
}
var online = navigator.onLine;
if (online) {
var data = {
site: {
collection_id: cId,
name: sname,
lat: slat,
lng: slng,
properties: p
}
};
//function sending to server
$.ajax({
url: App.URL_SITE + cId + "/sites?auth_token=" + storeToken(),
type: "POST",
data: data,
enctype: 'multipart/form-data',
crossDomain: true,
datatype: 'json',
cache: false,
contentType: false,
processData: false,
success: function(data) {
console.log("data: " + data);
alert("successfully.");
},
}
謝謝你的回答。但我不知道爲什麼FileUploadOptions沒有定義。我已經安裝了文件傳輸。 – SANSONAN
我想你會錯過在XML文件傳輸線。只需檢查您的xml文件是否添加或不添加。此外,如果您對我的答案感到滿意,只需通過選擇刻度標記接受它。謝謝 – Vinith