Hello everybody, I'm a newby on ExtJs but I've managed to overcome many problems reading forums and posts.
Now I have a little problem using a method POST.....and trying to pass array as params. But the real problem is due to String Array.........I explain...
I have a JsonStore
Code:
var store_clienti = new Ext.data.JsonStore({
url: 's_find_clienti.php',
root: 'data_root',
fields: ['id','livello','nome'],
autoLoad:true,
autoDestroy: false
});
Ok, now I made a function like that :
Code:
function esporta_griglia(store){
var array_id = new Array();
var array_livelli = new Array();
var array_nomi = new Array();
var i = 0;
store.each(function(record){
array_id[i] = parseInt(record.get('id'));
array_livelli[i] = record.get('livello');
array_nomi[i] = record.get('nome');
i++;
});
Ext.Ajax.request({
url: 's_prova.php',
params: {sarray_id:Ext.encode(array_id), sarray_livelli:Ext.encode(array_livelli), sarray_nomi:Ext.encode(array_nomi)}
method: 'POST',
success: function(result){
window.open('griglia.txt','nuovapagina','width=700,height=600');
},
failure: function() {
Ext.Msg.alert('Connection not executed!');
}
});
Ok, now the PHP script is this:
Code:
<?php
include("../common/common_php_header.php");
$array_id = array();
$array_livelli = array();
$array_nomi = array();
$array_id = json_decode($_POST['sarray_id']);
$array_livelli = json_decode($_POST['sarray_livelli']);
$array_nomi = json_decode($_POST['sarray_nomi']);
$identificatore = fopen("griglia.txt","w");
// Scrivo i dati nel file
fwrite($identificatore, $array_id[0]);
fwrite($identificatore, "---");
fwrite($identificatore, $array_livelli[0]);
fwrite($identificatore, "---");
fwrite($identificatore, $array_nomi[0]);
fclose($identificatore);
?>
What I pass with the encode method is this:
- sarray_id:
[11,782,588,682,781,683,385,384,263,157,54,60,350,352,386,387,589,70,324,608,193,71,65,413,272,194,393,440,195,273]
- sarray_livelli:
[3,2,1,0,1,0,1,1,2,3,1,1,1,2,1,2,0,0,2,1,2,0,2,1,0,0,2,2,0,0]
- sarray_nomi:
["something","something2","something3","something4",..........and so on]
And the result in the .txt file is this:
As you can imagine I've a problem with the array encode/decode methods.
For numeric arrays everything is fine, but with the string array I cannot decode it properly....
Could you please help me with this problem. Any suggest will be useful.
Thanks
and sorry for my english....