|
// 上传
Model.prototype.dataValueChanged = function(event) {
/*
* 1、获取上传图片,组合预览地址 2、生成上传图片的fID 3、将上传图片信息保存到paiData
*/
$.ajax({
type: "get",
"async" : false,
url: "http://192.168.1.177/wex5/post",
contentType: "application/json; charset=utf-8",
dataType: "jsonp",
jsonp: "CallBack",
data: "{}",
success: function(resultData) {
data.loadData(resultData);
},
error:function (){
alert("错误");
}
});
var data = this.comp('data');
var paiData = this.comp('paiData');
var row = data.getCurrentRow();
var jsonList = eval("(" + row.val('fileName') + ")");
jsonList[0].ownerID = row.getID();
var ownerID = row.getID();
var realFileName = jsonList[0]["realFileName"];
var storeFileName = jsonList[0]["storeFileName"];
var operateType = "preview";// 预览
var previewUrl = this.comp("attachmentSimple").getFileUrl(realFileName, storeFileName, ownerID, operateType);
var fid = 1;
if (paiData.getCount() > 0) {
paiData.last();
fid = paiData.getValue("fID") + 1;
}
var gpsDtd = this.getLocation();
gpsDtd.done(function(position) {
var positioning = position.latitude + "|" + position.longitude;
var options = {
defaultValues : [ {
fID : fid,// id
fFileName : realFileName,// 图片名
fPreviewPath : previewUrl,// 预览地址
fDownloadPath : JSON.stringify(jsonList),// 下载时需要的json串
fCreateTime : justep.Date.toString(new Date(), 'yyyy-MM-dd hh:mm:ss'),// 上传时间
fDescription : "",// 描述
fAddress : position.address,// 上传时地址
fPositioning : positioning
// 上传时坐标
} ]
};
paiData.newData(options);
paiData.saveData();
});
data.refreshData();
paiData.refreshData();
};
这是ajax代码段
public void service(ServletRequest request, ServletResponse response) throws ServletException, IOException {
//请求
String action = request.getParameter("action");
//回调函数名
String callback = request.getParameter("CallBack");
//控制器部分
if("checkAddress".equals(action)){
response.setContentType("text/html;charset=utf-8");
response.getWriter().write(callback+"({});");
}
}
这是后台回调的代码?为啥运行点击事件后ajax不运行呢? |
|