HttpHandlers, Javascript and Firefox

K

kiki

Hello,
I have the following code which works fine in IE, but can't get it to
work in Firefox. (the idea is to get DB data without postback).. I
would apreciate any ideas you might have on this..

Javascript:
........
function getList(gameId)
{
var handler = new clientHttpHandler();
var xmlInputs = oHandler.initialiseInputXML();
xmlInputs = handler.buildInputXML(xmlInputs, gameId,"gameId");
var xml= handler.finishInputXML(xmlInputs);
oHandler.processRequest("handlers/RoomList.ashx, "POST", xml, false,
true, displayList);
}

function displayList(myResult)
{
if(myResult.result == "")
{
document.getElementById("information").innerHTML = "No
Room Lists available."
}
else
{

document.getElementById("roomlist").innerHTML = myResult.result; }

}
........
Handler:
........
private string RoomLists(XPathDocument functionParams)
{
GameRequestHandlers roomList = new GameRequestHandlers ();
XPathNodeIterator iterator =
functionParams.CreateNavigator().SelectDescendants("gameId", "",
false);
iterator.MoveNext();
int gameId = Convert.ToInt32(iterator.Current.Value.ToString());
XmlDocument roomListXML = roomList.GetRoomList(gameId);

XslTransform xslt = new XslTransform();
XsltArgumentList xsltArg = new XsltArgumentList();
xsltArg.AddParam("GameId", "", gameId);

xslt.Load(HttpContext.Current.Server.MapPath("../Styles/RoomList.xslt"));
XmlElement root = roomListXML.DocumentElement;

// Create an XPathNavigator to use for the transform.
XPathNavigator nav = root.CreateNavigator();

// Transform the file.
return BuildData(nav, xslt, xsltArg);
}

private string BuildData (XPathNavigator XPathNav,XslTransform
xslT,XsltArgumentList XsltArguments)
{
MemoryStream ms=new MemoryStream();
StreamReader stream = new StreamReader (ms);
XmlUrlResolver xR = new XmlUrlResolver();
StringBuilder sbBuildDataXml = new StringBuilder();
try
{
xslT.Transform(XPathNav, XsltArguments, ms,xR);
ms.Seek( 0, SeekOrigin.Begin );
sbBuildDataXml.Append(stream.ReadToEnd());
return sbBuildDataXml.ToString();
}
catch (Exception ex)
{
return
string.Empty;

}
finally
{
ms.Close();
stream.Close();
}
}


Any ideas?
Thank you for your time..
 
M

Martin Honnen

I have the following code which works fine in IE, but can't get it to
work in Firefox.
function getList(gameId)
{
var handler = new clientHttpHandler();
^^^^^^^^^^^^^^^^^

What is that? Ask whoever wrote that function on how to use it with
Firefox or whether it is supposed to work with Firefox.

Then check Firefox's JavaScript console for error messages to find out
where something goes wrong.
 
K

kiki

Hello Martin and thank you for your reply. I completely forgot to post
the code for that function.
I did go through it though and sorted out a few browser issues.
I'm stuck on this now:

var xml = "<input><selectedGame>Domino</selectedGame></input>"
var oParamXML= document.implementation.createDocument("","",null);
oParamXML.load(xml);

in IE i'd do oParamXML.xml to view the loaded xml. What's the equiv in
Mozilla, or is there a way to view it?

Thanks again
 
M

Martin Honnen

var xml = "<input><selectedGame>Domino</selectedGame></input>"
var oParamXML= document.implementation.createDocument("","",null);
oParamXML.load(xml);

That is nonsense, Mozilla implements a method called load but that takes
a URI and not a string with XML as the argument. So load(xml) does not
make sense with xml being a string.

You probably want
var xmlDocument = new DOMParser().parseFromString(
xml,
'application/xml'
);
in IE i'd do oParamXML.xml to view the loaded xml. What's the equiv in
Mozilla, or is there a way to view it?

If you want to serialize an XML DOM node in Mozilla (and Opera) you can
use XMLSerializer e.g.
var serializedXML = new XMLSerializer().serializeToString(xmlDocument);

See also
<http://www.faqts.com/knowledge_base/index.phtml/fid/616>
with entries
<http://www.faqts.com/knowledge_base/view.phtml/aid/15302/fid/616>
<http://www.faqts.com/knowledge_base/view.phtml/aid/34646/fid/616>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,990
Messages
2,570,211
Members
46,796
Latest member
SteveBreed

Latest Threads

Top