PDA

View Full Version : XMLReader not loading from http but yes from xml file



jesdial
30 Jul 2007, 6:39 PM
Hello all and thank you in advance

I'm developing:

http://www.my3dgis.com/maps/visor.htm#

At Opciones > Catastro > Referencia Catastral i want to load a ComboBox using:


var pProxy = new Ext.data.ScriptTagProxy({url:'https://ovc.catastro.meh.es/ovcservweb/OVCSWLocalizacionRC/OVCCallejero.asmx/ConsultaProvincia'});

//var pProxy = new Ext.data.HttpProxy({url:'provincias.xml'});
//var pProxy = new Ext.data.MemoryProxy({load:'https://ovc.catastro.meh.es/ovcservweb/OVCSWLocalizacionRC/OVCCallejero.asmx/ConsultaProvincia', method: 'post'});

var pRecordDef = new Ext.data.Record.create([
{name: 'cpine', mapping:'cpine'},
{name: 'np', mapping :'np'}
]);

var pReader = new Ext.data.XmlReader({
record: 'prov',
id: 'cpine',
totalRecords: 'cuprov',
}, pRecordDef);

var dsProvincias = new Ext.data.Store({
proxy : pProxy ,
reader: pReader
});

........



new Ext.form.ComboBox({
emptyText:'Seleccione una provincia',
//typeAhead: true,
triggerAction: 'all',
width:135,
mode:'local',
valueField : 'cpine',
forceSelection:true,
store: dsProvincias,
displayField : 'np',
allowBlank:false,
name:'Provincias'
})
);

try
{
dsProvincias.load();
}
catch (e)
{
alert (e);
}



However:

1

jesdial
31 Jul 2007, 3:16 AM
Well

I've just noticed one error in my post.... (excuse me for this....)

This morning, i've changed my PC... and i'm now viewing a Firebug error:
"missing ; before statement
https://ovc.catastro.meh.es/ovcservweb/OVCSWLocalizacionRC/OVCCallejero.asmx/ConsultaProvincia?&_dc=1185876034602&callback=stcCallback1001
Line 2"
(i really don't know why it was not showing in my other PC....any suggestion?).

I've encountered this error arrises because ScriptTagProxy treats the request as Javascript... but i can wrap the response "in a callback function is the "callback" parameter is passed because a ScriptTagProxy requires executable javascript, not an object literal "
(http://extjs.com/forum/showthread.php?t=9281 )

Is there any sample anywhere of how to do this?

Thank you in adavance again

Jes

jesdial
31 Jul 2007, 3:25 AM
Well

I've just noticed one error in my post.... (excuse me for this....)

This morning, i've changed my PC... and i'm now viewing a Firebug error:
"missing ; before statement
https://ovc.catastro.meh.es/ovcservweb/OVCSWLocalizacionRC/OVCCallejero.asmx/ConsultaProvincia?&_dc=1185876034602&callback=stcCallback1001
Line 2"
(i really don't know why it was not showing in my other PC....any suggestion?).

I've encountered this error arrises because ScriptTagProxy treats the request as Javascript... but i can wrap the response "in a callback function is the "callback" parameter is passed because a ScriptTagProxy requires executable javascript, not an object literal "
(http://extjs.com/forum/showthread.php?t=9281 )

Is there any sample anywhere of how to do this?

Thank you in adavance again

Jes

mihg
3 Aug 2007, 11:46 AM
I am also having a similar problem but with the Interactive Demo Loading/Saving a Dynamic Form using XML. When I load the data into the form explicitly with the XML file provided it works fine. When I load the XML file from php JS EXT throws an not so descriptive error:

Here's the JS snippet verbatim from the interactive demo:



// simple button add
fs.addButton('Load', function(){
fs.load({url:'load_form.php', waitMsg:'Loading'});
});

// explicit add
var submit = fs.addButton({
text: 'Submit',
disabled:true,
handler: function(){
fs.doAction("submit", {url:'save-form.php', waitMsg:'Saving Data...'});
}
});


Here's the simple php page returning he same XML as xml-form.xml



<?php
echo "<?xml version=\"1.0\" encoding=\"UTF-8\"?>
<response success=\"true\">
<contact>
<name>
<first>Jack</first>
<last>Slocum</last>
</name>
<company>Ext JS</company>
<email>[email protected]</email>
<state>OH</state>
<dob>04/15/2007</dob>
</contact>
</response>";
?>



Here is the ERROR I see in FireBug:



uncaught exception: [object Object]


I have also attached an image of the error.

Thanks for the help!

mihg
10 Aug 2007, 7:28 AM
Well that was kind of naive of me ... if you're going to send dynamic xml data over http to something that is expecting xml data you should send down the appropriate headers:




ob_start();
header('Content-type: text/xml');
header('Content-Disposition: attachment; filename="xml-form.xml"');
header("Cache-Control: no-cache, must-revalidate"); // HTTP/1.1
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); // Date in the past

echo "<?xml version=\"1.0\" encoding=\"UTF-8\"?>
<response success=\"true\">
<contact>
<name>
<first>Jack</first>
<last>Slocum</last>
</name>
<company>Ext JS</company>
<email>[email protected]</email>
<state>OH</state>
<dob>04/15/2007</dob>
</contact>
</response>";
ob_end_flush();



This worked...:D