PDA

View Full Version : Datastore load exception



vitolini
2 Aug 2010, 2:25 PM
I am trying to load a combobox in roweditor for my grid. I copied the configuration of my combo from another form in which it works perfectly fine. However, this one doesn't load the data, The list opens, and I can see the "Searching..." text but I can't see the request being sent in firebug. And eventually it timesout with these parameters ...


argument: undefined
isAbort : true,
isTimeout: true,
status : -1,
statusText : 'transaction aborted',
tId : 1Here is the related piece of code...


{header: 'Origin',
id: 'location_from',
dataIndex:'location_from' ,
editor: new Ext.form.ComboBox({
store: locationLookupDataStore,
typeAhead: true,
displayField: 'port_code',
valueField: 'port_code',
loadingText: 'Searching...',
minChars: 3,
hideTrigger: true,
triggerAction: 'all' } )
}

locationLookupDataStore = new Ext.data.Store({
url: 'http://localhost/cgi-bin/get-locations.cgi',
baseParams: {db:'fgdemo', host: 'localhost'},
listeners: {
beforeLoad: function(store, options) {
//alert(options.params.url+":"+options.params.host);
return true;
},
load: function(store, records,options){
alert("loaded");
},
exception: function(obj, options, response, e){
console.info('store loadexception, arguments:', arguments);
console.info('error = ', e);
}

},
reader: new Ext.data.JsonReader({
root: 'results',
totalProperty: 'total',
idProperty: 'port_code',
fields : [{name: 'port_code'},
{name: 'city', mapping: 'city'},
{name: 'state', mapping: 'state_country'},
{name: 'iso_cc2'}
]
})
});And of course when I paste this url http://localhost/cgi-bin/get-locations.cgi?db=fgdemo&host=localhost&query=USLAX (http://localhost/cgi-bin/get-locations.cgi?db=fgdemo&host=localhost&query=USL) into my firefox i get back the json result without a problem...

here is the result

{"total":1,"results":[{"country":"United States (US)","city":"Los Angeles, CA, US","iso_cc2":"US","state_province":"","port_code":"USLAX"}]}I ve spent hours on this already to no avail :( any help will greatly be appreciated

Condor
2 Aug 2010, 11:59 PM
If you paste the url in the browser it will do a GET request, but your store will do a POST request by default (unless you configure it with a proxy with method:'GET'.

Could it be that your server can't handle POST requests?

ps. You can debug XHR requests using add-ons like Firebug or Fiddler2.

vitolini
3 Aug 2010, 12:06 AM
I access the same cgi function with ext store using a POST method, but i just realized the difference is that, the other code is from a cgi to this cgi so its both under the same apache...

In this case this request is sent from tomcat (localhost:8080) to apache on the localhost... my guess is that it might be the javascript not being able to make a call to another servlet/port... I know that's why we have HttpProxy class and I used that too but it did the same thing :(

I changed it this way...


locationLookupDataStore = new Ext.data.Store({
proxy : new Ext.data.HttpProxy({
url: 'http://localhost/cgi-bin/get-locations.cgi'
}),
baseParams: {db:'fgdemo', host: 'localhost'},
listeners: {
beforeLoad: function(store, options) {
//alert(options.params.url+":"+options.params.host);
return true;
},
load: function(store, records,options){
alert("loaded");
},
exception: function(obj, options, response, e){
console.info('store loadexception, arguments:', arguments);
console.info('error = ', e);
}

},
reader: new Ext.data.JsonReader({
root: 'results',
totalProperty: 'total',
idProperty: 'port_code',
fields : [{name: 'port_code'},
{name: 'city', mapping: 'city'},
{name: 'state', mapping: 'state_country'},
{name: 'iso_cc2'}
]
})
});any other ideas???

vitolini
3 Aug 2010, 10:14 AM
Yes, it does handle POST's also. I am calling this get-locations.cgi from 2 different places. The other is also an Ext combobox with a store. The difference is that the second is called from within apache in localhost. In this case where I have the problem, it's called fromtomcat on localhost:8080 to the apache (where the cgi is) so my guess is that it might be that the javascript can't make a call to another server/port issue. And i know that's why we have the HttpProxy class. So I went ahead and changed my store to use HttpProxy but it didn't help either. Here is my last change...


locationLookupDataStore = new Ext.data.Store({
proxy : new Ext.data.HttpProxy({
url: 'http://localhost:8080/get-locations.cgi',
method : 'POST'
}),

baseParams: {db:'fgdemo', host: 'localhost'},
listeners: {
beforeLoad: function(store, options) {
//alert(options.params.url+":"+options.params.host);
return true;
},
load: function(store, records,options){
alert("loaded");
},
exception: function(obj, options, response, e){
//console.info('store loadexception, arguments:', arguments);
//console.info('error = ', e);
}

},
reader: new Ext.data.JsonReader({
root: 'results',
totalProperty: 'total',
idProperty: 'port_code',
fields : [{name: 'port_code'},
{name: 'city', mapping: 'city'},
{name: 'state', mapping: 'state_country'},
{name: 'iso_cc2'}
]
})
});

any other ideas?

Condor
3 Aug 2010, 11:44 PM
Indeed, you are not allowed to make a request to another domain (= server + port).

The only exception is a ScriptTagProxy (but you will need to modify your cgi so it uses the correct callback syntax).