post
サンプルコード
function HTTPPostMultipart () {
var url = "http://some.url/post.php";
var postData = {
param1 : "applican",
param2 : "test"
};
var postFile = [{
name : "image",
fileName : "image.jpg",
contentType : "image/jpeg",
data : "U29tZSBzYW1wbGUgc3RyaW5n"
}];
var postHeaders = {
"Content-Type" : "image/jpeg"
};
var options = {
post : postData,
postFile : postFile,
timeout : 10000,
headers : postHeaders
};
applican.http.post(url, options, httpPostSuccess, httpPostError);
}
function httpPostSuccess(result){
alert(result);
}
function httpPostError(message){
alert(message);
}
function HTTPPostSimple(){
var url = "http://some.url/post.php";
var postData = {
param1:”some_data",
param2:”some_data"
};
var postHeaders = {
"Header 1":"Contents 1",
"Header 2":"Contents 2",
"Header 3":"Contents 3"
};
var options = {post:postData, timeout:10000, headers: postHeaders};
applican.http.post(url, options, httpPostSuccess, httpPostError);
}
function httpPostSuccess(result){
alert(result);
}
function httpPostError(message){
alert(message);
}
function HTTPPostJson(){
var url = "http://some.url/post.php";
var postData = {
param1: "json1",
param2: true,
param3: 12344,
param4: {
param5: 'aaaa',
param6: [ 111, 'avbrr', true, null ]
}
};
var options = {
headers: { "Content-Type": "application/json" },
post: postData,
timeout: 10000
};
applican.http.post(url, options, httpPostSuccess, httpPostError);
function httpPostSuccess(result){
alert(result);
}
function httpPostError(message){
alert(message);
}