Saturday, March 24, 2012

Works in IE but not in Firefox ...

Hi all

I have a simple script for those of you who are not scared of a bit of Javascript, which works perfectly in IE, but fails in Firefox with the following error

Error: uncaught exception: [Exception... "Not enough arguments [nsIDOM3Node.getUserData]" nsresult: "0x80570001 (NS_ERROR_XPC_NOT_ENOUGH_ARGS)" location: "JS frame ::http://localhost:2690/AtlasAprilCTPTests/Default.aspx :: onclick :: line 1" data: no]

Here is the code, pretty simple stuff. Any ideas anyone?

<%@dotnet.itags.org.PageLanguage="C#"%>
<%@dotnet.itags.org.ImportNamespace="System.Web.Services" %>
<%@dotnet.itags.org.ImportNamespace="System.Data" %>
<!DOCTYPEhtmlPUBLIC"-//W3C//DTD XHTML 1.1//EN""http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<htmlxmlns="http://www.w3.org/1999/xhtml">
<headid="Head1"runat="server">
<atlas:ScriptManagerID="ScriptManager1"EnablePartialRendering="true"EnableScriptComponents="true"runat="server"/>
<scripttype="text/C#"runat="server">
[WebMethod]
publicDataTable getUsers()
{
DataSet1TableAdapters.tblUsersTableAdapter da =new DataSet1TableAdapters.tblUsersTableAdapter();
return da.GetData();
}
</script>
<scripttype="text/javascript">
function getUserData()
{
PageMethods.getUsers(reportData, reportTimeOut, reportError);
}
function reportData(result)
{
if(result)
{
var sb =new Array();
sb.push("<table border=1 style=\"border-collapse:collapse;\"><tr><td>UserID</td><td>Firstname</td><td>Surname</td><td>DOB</td><td>isSubscribed</td></tr>");
for(var i=0; i<result.get_length();i++)
{
sb.push("<tr><td>" + result.getItem(i).get_rowObject().UserID +"</td><td>" + result.getItem(i).get_rowObject().FirstName +"</td><td>" + result.getItem(i).get_rowObject().Surname +"</td><td>" + result.getItem(i).get_rowObject().DOB +"</td><td>" + result.getItem(i).get_rowObject().isSubscribed +"</td></tr>");
}
sb.push("</table>");
$("result").innerHTML = sb.join("");
}
}
function reportError(result)
{
alert(result);
}
function reportTimeOut(result)
{
alert(result);
}
</script>
</head>
<body>
<formid="form1"runat="server">
<div>
<inputtype="button"value="Get Table From DB"onclick="getUserData();"/>
</div>
<divid="result"></div>
</form>
</body>
</html>

Cheers

Martin

Hi Martin,

For some reason, it appears that Firefox doesn't like the name 'getUserData'. Rename it and it should all work. Maybe the name conflicts with a built-in Firefox function or something like that.

Maybe someone else can provide an explanation?

thanks,
David


Yes David is correct. Th problem is with getUserData which is a function defined in the DOM level 3 specification.

http://www.w3.org/TR/DOM-Level-3-Core/idl-definitions.html

The DOM function needs a parameter of type string. So if you rename the function it will work out.

No comments:

Post a Comment