PDA

View Full Version : HttpProxy not requesting results



jdaum
19 Jun 2007, 6:33 PM
Hi,

I'm going through the video tutorial http://extjs.com/grid-tutorial/ by Scot Walter, but have replaced the dataSource with HTTPProxy/XMLReader. I am stuck at the point where Scott uses the Firebug console to run gridUI.getDataSource().getTotalCount(). I'm not getting any data or any count. It appears that the HTTP proxy is not connecting to the server to get the xml file. All this is running on a local development environment.

Here is my grid code:

[PHP]<script type="text/javascript">
var gridUI = function(){

var ds;
var grid;
var columnModel;

function setupDataSource(){

ds = new Ext.data.Store({
proxy: new Ext.data.HttpProxy({
url: 'http://kpextjs.example.com/sheldon.php?data=test'
}),
reader: new Ext.data.XmlReader({
// records will have an

Animal
19 Jun 2007, 11:51 PM
You are running that page from http://kpextjs.example.com/ aren't you?

Because you can't make HttpProxy connections cross-domain.

jdaum
20 Jun 2007, 12:49 PM
Hi,

thanks for the answer. Yes its all on the same domain. I will complete the script and then post here, if I am still stuck.

Regards,

Jochen

Animal
20 Jun 2007, 11:18 PM
Your record definition isn't right. It shohld be an Array.

But use ext-all-debug.js and step into ds.load() and see what happens.

jdaum
21 Jun 2007, 1:37 PM
Hi,

thanks again for pointers.


I'm not quite sure what you mean by record definition. Isn't the [ ] creating an array as a second argument to Ext.data.XmlReader. I have debugged into ds.load() until the Ajax request is sent. The URL seems right, but there is no server request triggered. I have also removed parameters from the request, just in case.

In regards to the setup of the XML reader matching the XML file, it seems to make more sense for this XML file


<Item>
<ASIN>0446355453</ASIN>
<DetailPageURL>
http://www.amazon.com/gp/redirect.html%3FASIN=0446355453%26tag=ws%26lcode=xm2%26cID=2025%26ccmID=165953%26location=/o/ASIN/0446355453%253FSubscriptionId=1A7XKHR5BYD0WPJVQEG2
</DetailPageURL>
<ItemAttributes>
<Author>Sidney Sheldon</Author>
<Manufacturer>Warner Books</Manufacturer>
<ProductGroup>Book</ProductGroup>
<Title>Master of the Game</Title>
</ItemAttributes>
</Item>


to use this definition:



function setupDataSource(){

ds = new Ext.data.Store({
proxy: new Ext.data.HttpProxy({
url: 'http://kpextjs.example.com/sheldon.php?data=test'
}),
reader: new Ext.data.XmlReader({
// records will have an "Item" tag
record: 'Item',
id: 'ASIN',
totalRecords: '@total'
}, [
// set up the fields mapping into the xml doc
// The first needs mapping, the others are very basic
{
name: 'Author', mapping: 'ItemAttributes > Author'
},
{
name: 'Title', mapping: 'ItemAttributes > Title'
},
{
name: 'Manufacturer', mapping: 'ItemAttributes > Manufacturer'
},
{
name: 'ProductGroup', mapping: 'ItemAttributes > ProductGroup'
}
])
});



I'm still not sure what is wrong. Further help appreciated.

Jochen

dnixon
21 Jun 2007, 5:12 PM
I have a similar problem with a Store that seems not to receive data.
I have several other Stores working fine - all the working ones are feeding data into grids.
The non-working one is just a Store with HttpProxy and XmlReader.
If I make the same http request directly (not through HttpProxy) I get what appears to be good data back from the server. I have traced this using firebug into the Store.load() method and the data is making it into the XmlReader but the Store has no records when either on('load') or on('datachanged') is called. It looks like q.select in XmlReader.readRecords()



var ns = q.select(this.meta.record, root);


is not matching the single record in the response although the XmlReader record tag and the root tag of the response object match exactly.
My XML looks like


<rec>
<one>def</one>
<two>abc</two>
</rec>

and my Store code is


ds = new Ext.data.Store({

proxy: new Ext.data.HttpProxy({url: 'http://whatever'}),

reader: new Ext.data.XmlReader({
record: 'rec'
}, [
'one', 'two'
])
});
.
.
.
ds.load();

tryanDLS
21 Jun 2007, 5:19 PM
What's in the root property. Didi you return the correct content-type?

dnixon
21 Jun 2007, 5:44 PM
Seems that line 668 in ext-all-debug.js (1.1b1):


cs = ni.getElementsByTagName(tagName);

is not matching anything (cs is empty on return) even though according to firebug


tagName = "rec";

and

ni.tagName = "rec";


???

dnixon
21 Jun 2007, 5:52 PM
Content-Type: application/xml

same for all the responses including the Stores that are working.

root contains exactly what I'm expecting to see "rec" + child nodes.

dnixon
21 Jun 2007, 6:02 PM
Is the fact the Store is not hooked up to any UI an issue? I am just adding a Store.on('load') listener and expecting to grab a value out of the Record - but no Records appear in Store.

tryanDLS
21 Jun 2007, 6:19 PM
Store doesn't have to be connected to UI. Can you browse to that xml file in IE/FF - does it parse correctly? Does this problem happen in both browsers? Just for the heck of it can you change your record def to put field names and mappings in (e.g name:'f1', mapping:'one', etc)

jdaum
22 Jun 2007, 7:24 PM
Hi,

I have tried the whole process from scratch again with the grid-xml example code. It works in IE, but not in FF.

As there are other JS libraries involved, I have removed them step by step. It appears that using Rico-1.1.2 is causing the problem. I understand that I will find most of the functionality of Rico in Extjs, but it would be easier, if I could apply extjs step by step to my sites that use Rico.

Does anyone have comments on this?

Jochen

jesdial
25 Jun 2007, 4:10 AM
I tkink i've a similar problem...

http://extjs.com/forum/showthread.php?t=8178

However, i'm using:

proxy: new Ext.data.HttpProxy(new Ext.data.Connection({url: 'tutorial.php', method: 'post'}))

instead of:

proxy: new Ext.data.HttpProxy({url: 'tutorial.php'})

i can see the XML requested with Firebug. However, the XMLReader...
does read nothing...

Jes

watrboy00
27 Sep 2007, 10:38 PM
I too think I am experiencing the same issue (http://extjs.com/forum/showthread.php?t=13743). From what I gather it seems to be a cross domain issue in FF even though for me I am requesting all the info from the same domain.