jquery mobile代碼如下總是失敗
提示request failed
、$().ready(function ()
{
$('#save').click(function (e)
{
CalluploaderHandler();
});
});
function CalluploaderHandler()
{
$.ajax({
type: "POST",
url: "Services/UPloader.ashx",
contentType: "application/json; charset=utf-8",
success: OnComplete,
error: OnFail
});
return false;
}
function OnComplete(result)
{
alert('Success');
}
function OnFail(result)
{
alert('Request failed');
}
拍照:
function capturePhoto() {
navigator.camera.getPicture(uploadPhoto, onFail, {
quality: 50, destinationType: Camera.DestinationType.FILE_URI
});
}
上傳
function uploadPhoto(imageURI) {
window.resolveLocalFileSystemURI(imageURI, function (fileEntry) {
fileEntry.file(function (fileObj) {
var path = fileObj.fullPath;
console.log("FilePath=" + path);
var options = new FileUploadOptions();
options.fileKey = "file";
var imagefilename = Number(new Date()) + ".jpg";
options.fileName = imagefilename;
options.mimeType = "multipart/form-data";
options.headers = {
Connection: "close"
};
var params = {
//....
};
options.params = params;
options.chunkedMode = false;
var ft = new FileTransfer();
var url = URL;
ft.upload(path, encodeURI(URL), win, fail, options, true);
});
});
}