1. #1
    Ext User
    Join Date
    Oct 2007
    Posts
    15
    Vote Rating
    0
    staka is on a distinguished road

      0  

    Default JS Error

    JS Error


    Okay, i've got this error in firebug:
    "Index or size is negative or greater than the allowed amount" code: "1"

    This is when I do ajax POST request, but everything seems to be normal.. I saw my POST request, params, variables & response.. & nothing wrong..
    I don't know what is this error.. & don't know how to fix it..

    ... and.. this is the code
    Code:
    function init_show_art() {
    	var art_ids = new Array();
    	var art_names = new Array();
    
    	Ext.Ajax.request({
    		url: 'some.php',
    		success: function suc(q) {
    			responseData = eval('(' + q.responseText + ')');
                            //art_ids = new Array();
                            //art_names = new Array();
    			//for (var n=0; n<responseData.all; n++) {
    				//art_ids[n] = responseData.root[n].art_id;
    				//art_names[n] = responseData.root[n].art_name;
    			//}
    
    			var hm = "{items: ["
    				+"new Ext.menu.CheckItem({ text: 'All', value: '0', checked: true, group: 'filter', handler: function(q,w) {"
    					+"filBut.setText('All');"
    					+"ds.load({params: {start:0, limit:pageSize}});"
    				+"}}),";
    			for (var n=0; n<responseData.all; n++) {
    				hm=hm+"new Ext.menu.CheckItem({ text: '"+responseData.root[n].art_name+"', value: '"+responseData.root[n].art_id+"', checked: false, group: 'filter', handler: function(q,w) {"
    						+"filBut.setText('"+responseData.root[n].art_name+"');"
    						+"var art_type="+responseData.root[n].art_id+";"
    						+"ds.load({params: {start:0, limit:pageSize, art_type:art_type}});"
    					+"}}),";
    			}
    			hm=hm+"]};";
    			create_grid('0','12',hm);
    		},
    		params: { get_art_types: '1' }
    	});
    };
    function create_grid(art_type,pageSize,hm) {
    	//var pageSize = 12;
    	var list_arts = eval(hm);
    
    	var ds = new Ext.data.Store({
    		proxy: new Ext.data.HttpProxy({
    			url: 'some.php?take_list=1'
    		}),
    		reader: new Ext.data.JsonReader({
    			root: 'root',
    			totalProperty: 'all',
    			id: 'id'
    		},[
    			{name: 'id', type: 'int'},
    			{name: 'title'},
    			{name: 'type'},
    			{name: 'status'},
    			//{name: 'createdon', type: 'date', dateFormat: 'Y-m-d H:i:s'}
    		])
        });
    
    	var fm = Ext.form, Ed = Ext.grid.GridEditor;
    
    	statuses = [
    		['not active'],
    		['active']
    	];
    	var ppstore = new Ext.data.SimpleStore({
    		fields: ['txt'],
    		data : statuses
    	});
    	var cm = new Ext.grid.ColumnModel([{
    		header: "Title",
    		dataIndex: 'title',
    		width: 100,
    		renderer: create_link,
    		editor: new Ed(new fm.TextField({
    			allowBlank: false
    		}))
    	},{
    		header: "Status",
    		dataIndex: 'status',
    		renderer: status,
    		editor: new Ed(new Ext.form.ComboBox({
    			mode: 'local',
    			typeAhead: true,
    			triggerAction: 'all',
    			lazyRender: true,
    			store: ppstore,
    			displayField: 'txt',
    			selectOnFocus: true,
    			//listWidth: 100
    		}))
    	},{
    		header: "Created",
    		dataIndex: 'createdon',
    		renderer: Ext.util.Format.dateRenderer('d.m.Y')
    	}]);
    	function create_link(q,w,e,r) {
    		return '<a href="#art" onclick="get_link(); function get_link() { '+grid.getSelectionModel().selectRow(r)+'; location.href=\'/art'+grid.getSelectionModel().getSelected().get("id")+'/\'; }; return false;">'+q+'</a>';
    	}; function status(q) {
    		return q==0?'<span style="color: #CC0000;">not active</span>':'active';
    	};
    	cm.defaultSortable = true;
    
    	var grid = new Ext.grid.EditorGrid('list_arts', {
    		ds: ds,
    		cm: cm,
    		selModel: new Ext.grid.RowSelectionModel(),
    		enableColLock:false,
    		loadMask: true,
    		autoSizeColumns: true
    	});
    
    	grid.on('afteredit', function() {
    		var editRow = grid.getSelectionModel().getSelected();
    		ds.load({params: {start:0, limit:pageSize, edit:1, id:editRow.get('id'), title:editRow.get('title'), status:editRow.get('status')=="active"?"1":"0",  art_type:art_type}});
    	});
    
    	var rz = new Ext.Resizable('list_arts', {
    		wrap:true,
    		minHeight:100,
    		pinned:true,
    		handles: 's'
    	});
    	rz.on('resize', grid.autoSize, grid);
    
    	grid.render();
    
    	var gridHead = grid.getView().getHeaderPanel(true);
    	var tb = new Ext.Toolbar(gridHead);
    
    	var newBut = new Ext.Toolbar.Button({
    		text: 'New article',
    		handler: function() {
    			$('#articles_div').load("some.php?some_variables=some_values");
    		}
    	});
    	tb.add(newBut);
    
    	var delBut = new Ext.Toolbar.Button({
    		text: 'Delete',
    		handler: del
    	});
    	function del() {
    		var allSel = grid.getSelectionModel().getCount();
    		var last = allSel==1?'this item':'these items';
    		if (allSel > 0) {
    			Ext.Msg.confirm('Message', 'Do you really want to delete ' + last + '?', del2);
    		} else { Ext.Msg.alert('Message', 'Please select at least 1 item'); }
    	}; function del2 (btn) {
    		if (btn == "yes") {
    			var m = grid.getSelections();
    			var delRows = "[";
    			for (var i = 0, len = m.length; i < len; i++) {
    				var delRow = "{\"id\":\""+m[i].get("id")+"\"}";
    				var last = (i+1)==len?"":",";
    				delRows = delRows + delRow + last;
    			}
    			delRows = delRows + "]";
    			ds.load({params:{start:0, limit:pageSize, delRows:delRows, art_type:art_type}});
    		}
    	};
    	tb.add('-');
    	tb.add(delBut);
    
    	var resBut = new Ext.Toolbar.Button({
    		handler: addRes,
    		cls: 'resources_add',
    		minWidth: 22
    	});
    	function addRes() {
    		var allSel = grid.getSelectionModel().getCount();
    		if (allSel>1) {
    			Ext.Msg.alert('Message','Please select only 1 item');
    		} else if (allSel==0) {
    			Ext.Msg.alert('Message','Please select at least 1 item');
    		} else {
    			var m = grid.getSelectionModel().getSelected().get('id');
    			$('#articles_div').load("some.php?some_variables=some_values");
    		}
    	};
    	tb.add('-');
    	tb.add(resBut);
    
    	var mpBut = new Ext.Toolbar.Button({
    		handler: addMP,
    		cls: 'image_add',
    		minWidth: 22
    	});
    	function addMP() {
    
    	};
    	tb.addSpacer();tb.addSpacer();tb.addSpacer();
    	tb.add(mpBut);
    
    	var filBut = new Ext.Toolbar.Button({
    		//icon: 'public/image/list-items.gif',
    		//cls: 'x-btn-text-icon',
    		text: 'Select type',
    		tooltip: 'Select one of types',
    		menu: list_arts,
    		//minWidth: 105
    	});
    	tb.add('-');
    	tb.add(filBut);
    
    	var gridFoot = grid.getView().getFooterPanel(true);
    	var paging = new Ext.PagingToolbar(gridFoot, ds, {
    		pageSize: pageSize,
    		displayInfo: true,
    		displayMsg: 'Displaying articles {0} - {1} of {2}',
    		emptyMsg: "No articles to display"
    	});
    
    	ds.load({params:{start:0, limit:pageSize, art_type:art_type}});
    	grid.getSelectionModel().selectRow(0);
    };
    
    $(document).ready(function() {
    	Ext.onReady(function() {
    		init_show_art();
    	});
    });

  2. #2
    Ext User
    Join Date
    Sep 2007
    Location
    chile
    Posts
    73
    Vote Rating
    0
    evilized is on a distinguished road

      0  

    Default


    Hi, i was with the same problem a time ago....

    i can solver this with like the follow code:

    PHP Code:
    art_ids = [];
    art_names=[];

    art_ids.push(responseData.root[n].art_id);
    art_names.push(responseData.root[n].art_name); 
    la musica es absolutamente necesaria para la vida.

  3. #3
    Ext User
    Join Date
    Oct 2007
    Posts
    15
    Vote Rating
    0
    staka is on a distinguished road

      0  

    Default ..

    ..


    Infact art_ids and art_names were just for test the responseData, and in real script i don't use them.. and the error still exists..

  4. #4
    Sencha User
    Join Date
    Mar 2007
    Posts
    7,854
    Vote Rating
    2
    tryanDLS is on a distinguished road

      0  

    Default


    Set a BP there and step thru the code - your trying to access an array element that doesn't exist. Break those huge concatenations apart and look at the pieces.

  5. #5
    Ext User
    Join Date
    Oct 2007
    Posts
    15
    Vote Rating
    0
    staka is on a distinguished road

      0  

    Default SOLVE

    SOLVE


    Yeah, finally i solved the problem..

    just before to load new data in ds, i must clear the old one..

    Code:
    .......
    ds.removeAll();
    ds.load({params: {some_vars: some_vals}});
    .......

Thread Participants: 2

film izle

hd film izle

film sitesi

takipci kazanma sitesi

takipci kazanma sitesi

güzel olan herşey

takipci alma sitesi

komik eğlenceli videolar