PhoneGap文件上传使用jQuery Ajax [英] PhoneGap File Upload Using jQuery Ajax
问题描述
我使用ajax,因为我想避免从网页重定向(当然,我想重定向到我自己的网页)。
所以,这里是我的一些代码:
$ $ $ $ $ $ ajax({
url:url,
data:$(#myform)。serialize(),
type:post,
dataType:json
});
以下我已经尝试了这些组合,但没有任何效果。有什么想法吗?
$ p $ contentType:false
cache:false
processData:false
contentType: multipart / form-data
必须使用PhoneGap的FileTransfer类。
文档和一些示例代码在这里: http://docs.phonegap.com/en/2.0.0/cordova_file_file.md.html#FileTransfer
I develop mobile app using PhoneGap and wanna ask if there is a way to upload a file to server (php) using jQuery's ajax. I use ajax because I want to avoid redirection from a web page (Of course, I want to redirect to my own page). So, here is some of my code:
$.ajax({
url: url,
data: $("#myform").serialize(),
type: "post",
dataType: "json"
});
and I've tried these combinations below but nothing works. Any idea ?
contentType: false
cache: false
processData: false
contentType: "multipart/form-data"
You'll probably have to use PhoneGap's FileTransfer class.
Documentation and some example code is here: http://docs.phonegap.com/en/2.0.0/cordova_file_file.md.html#FileTransfer
这篇关于PhoneGap文件上传使用jQuery Ajax的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!