PDA

View Full Version : cross domain requests using ext.data.httpproxy



sarah eldaw
10 Apr 2012, 6:23 AM
Hello..am trying to activate the autocomplete feature of Ext.form.combobx using the following code:

var RecordDef = Ext.data.Record.create([
{name: 'description', mapping: 'description'},
{name: 'lat' , mapping: 'lat'},
{name: 'lng' , mapping:'lng'}
]);
var ds = new Ext.data.Store({
model: 'RecordDef',
proxy: new Ext.data.HttpProxy({url:'geo-multi.xml', method:'GET'}),
reader: new Ext.data.XmlReader({
root : 'geocoderResults',
totalRecords: 'count',
record: 'result'
})
});


var timePanel = {
xtype: 'panel',
border: false,
width: 600,
bodyPadding: 10,
layout: 'anchor',

items: [{
xtype: 'combo',
displayField: 'title',
store: ds,
typeAhead: false,
hideLabel: true,
hideTrigger:true,
anchor: '100%',
listConfig: {
loadingText: 'Searching...',
emptyText: 'No matching posts found.',

// Custom rendering template for each item
getInnerTpl: function() {
return '<div class="search-item">' +
'<h3><span>{[Ext.Date.format(values.lastPost, "M j, Y")]}<br />by {author}</span>{title}</h3>' +
'{excerpt}' +
'</div>';
}
},
pageSize: 10,
},

{
xtype: 'component',
style: 'margin-top:16px',
html: 'live search'
}]
};
I have the following problem:
1- the returned xml content type header is not xml but instead html and this is the output from firebug console:


Connection
Keep-Alive


Content-Length
409


Content-Type
text/html;charset=ISO-8859-1


Date
Tue, 10 Apr 2012 14:08:29 GMT


Last-Modified
Sun, 08 Jan 2012 08:11:37 GMT


Server
Winstone Servlet Engine v0.9.10


X-Powered-By
Servlet/2.5 (Winstone/0.9.10)


this is the first problem
my second problem is that i have a php code that am using to generate my xml file, and its resident in a different domain from the application that am trying to activate the autocomplete combobox....how can i make cross domain requests through ext.data.scripttagproxy , which is not working in my case and giving me lots of errors ... can any one help please

mitchellsimoens
12 Apr 2012, 12:09 PM
The PHP code will need to adjust the header of the response.

Ajax proxy (there technically is no http proxy anymore, it was renamed to ajax) cannot do cross origin requests. JsonP allows the ability to do cross domain requests but requires JSON and a valid JsonP response.