PDA

View Full Version : Strange HttpProxy response



hallikpapa
16 Aug 2007, 4:52 PM
I have a perl script that was working great until recently. The page and grid are written by a separate script. This is the js file that loads the grid and calls for data



var myGrid = function() {
return {
init: function() {
//we enable the QuickTips for the later Pagebar
Ext.QuickTips.init();

var cookies = new Ext.state.CookieProvider();
Ext.state.Manager.setProvider( cookies );
var gettingStartedDefault = cookies.get( "reportDate" );

// Menus can be prebuilt and passed by reference
var dateMenu = new Ext.menu.DateMenu({
handler : function(dp, date){
Ext.example.msg('Date Selected', 'You chose {0}.', date.format('M j, Y'));
cookies.set( "reportDate", date.format('Y-m-j'));
}
});

// create the Data Store
var ds = new Ext.data.Store({
proxy: new Ext.data.HttpProxy({url: '../../../cgi-bin/rpt.pl?dataname=ASRHOUR'}),
reader: new Ext.data.JsonReader({
root: 'myData',
totalProperty: 'totalCount',
id: 'id'
},
[
{name: 'ID', mapping: 'id', type: 'string'},
{name: 'Col2', mapping: 'col2', type: 'string'},
{name: 'Col3', mapping: 'col3', type: 'string'},
{name: 'Col4', mapping: 'col4', type: 'string'},
{name: 'Col5', mapping: 'col5'},
{name: 'Col6', mapping: 'col6'},
{name: 'Col7', mapping: 'col7'},
{name: 'Col8', mapping: 'col8'},
{name: 'Col9', mapping: 'col9'},
{name: 'Col10', mapping: 'col10'}
]),
// turn on remote sorting
remoteSort: true
});
//we set the deafault sort to the id ascending
ds.setDefaultSort('ID', 'asc');


// now we create the Grid Columns
var cm = new Ext.grid.ColumnModel([
{header: "Date.Hour", dataIndex: 'ID', width: 125, sortable: true, align: 'left'},
{header: "", dataIndex: 'Col2', width: 125, sortable: true},
{header: "Attempts", dataIndex: 'Col3', width: 70, sortable: true},
{header: "Connects", dataIndex: 'Col4', width: 70, sortable: true},
{header: "Errors", dataIndex: 'Col5', width: 70, sortable: true},
{header: "Minutes", dataIndex: 'Col6', width: 70, sortable: true},
{header: "ASR", dataIndex: 'Col7', width: 70, sortable: true},
{header: "PDD", dataIndex: 'Col8', width: 70, sortable: true},
{header: "ACD", dataIndex: 'Col9', width: 70, sortable: true},
{header: "Last Call", dataIndex: 'Col10', width: 150, sortable: true}
]);
// by default columns are sortable
cm.defaultSortable = true;

// create the grid
var grid = new Ext.grid.Grid('grid', {
ds: ds,
cm: cm,
selModel: new Ext.grid.RowSelectionModel({singleSelect:true}),
loadMask: true,
enableColLock:true
});
// render the Grid
grid.render();

var gridFoot = grid.getView().getFooterPanel(true);
// add a paging toolbar to the grid's footer
var pagbar = new Ext.PagingToolbar(gridFoot, ds, {pageSize: 12});

ds.load({params:{start:0, limit:12}});
...............
...............

So as you can see, it's trying to execute
cgi-bin/rpt.pl?dataname=ASRHOUR

Which I can see in firebug that is what is being called. I have a CGI setup in perl to catch it, cause if I execute that url directly, it posts JSON data perfectly. But it's dying when I launch it via the html.

I posted the contents of my parameters string to a text file to see why it's not capturing dataname=ASRHOUR

and this is what parameters it is getting:



$VAR1 = {

'start' => '0',

'limit' => '12',

'sort' => 'ID',

'dir' => 'ASC'

};

Extremely strange. I am using the stable release of 1.1. I get no js errors or warnings, just the perl dying cause it is not receiving a dataname parameter. Is there anything you see in my js above that would indicate why it's passing the sorting stuff in the RESPONSE? I see the above variables in the POST too, but under PARAM in firebug, it shows dataname ASRHOUR

and incase anyone knows perl, the first thing I do in the script is

$query = CGI->new;
$reportname = $query->param('dataname');

But in my testing, $reportname is never populated. If I hard code it, script works great. So it's not being passed to the perl correctly.

Can anyone see what may be causing those 4 variables to be passed into dataname???

hendricd
17 Aug 2007, 5:56 AM
ds.load({params:{start:0, limit:12, dataname:'ASRHOUR'}});

You should reserve you parameter defs for the load call. Keep the URL clean (no params). Ext does the rest.