wyver
October 12, 2015, 2:08pm
1
Hi,
I would like to use FileTransfer to transfert a file with POST params. if i wirte
var params = {};
params.value1 = 'test';
...
It’s work fine, but when i write :
var params {arrayValue : ''};
params.arrayValue = {value1: 'test', value2: 'test'};
It does’nt work. I can’t access to arrayValue…
Can you help me ?
Thank You
do you mean:
var params = {
arrayValue: ''
};
btw {} = Object and [] = Array
implicit an array is also an object… but to be clear Object = {key: value}, Array = [value, value2]
1 Like
wyver
October 12, 2015, 2:23pm
3
Yeah but i would like an array with key / value and this value is an another array key / value.
Thank you very much
you have to set something like that:
var params {
myArrayParam: ['1', '2', '3']
};
// console.log(params.myArrayParams[0]);
wyver
October 12, 2015, 2:28pm
5
Thank you
It’s not possible to make something like this ?
var params = {
data : {
title : ‘test’
}
};
yeah but than it is not an array it is an object:
var params = {
firstName: 'Hans',
lastName: 'Wurst'
}
wyver
October 12, 2015, 2:47pm
7
Thank you ^^ but it’s another issuer . i’ve a back end in PHP, and when i post my data, i’ve got an Object like this :
var object = { data : { title : ‘value’, categorie: ‘value2’, … }}; when i make an object like this, it doesn’t work …, but whien i make a basic http.post, it’s work.
Thank you for your help
maybe your PHP backend is not configured to handle JSON request body data per default.
AngularJS is sending the data in contentype application/json
1 Like
wyver
October 12, 2015, 3:37pm
9
I make this :
var params = {};
params.value1 = JSON.stringify({title: 'title'});
And it works fine thank you very much
I would not make this on clientside. You can simple parse json data in your php-backend