From: Ahmed A. <asa...@ya...> - 2009-02-08 19:07:01
|
Dear Sling, I am not able to reproduce. The below case succeeds by HtmlUnit with FF simulation. Are you using latest 2.4 version? Also, I believe HtmlUnit incorrectly doesn't handle "XMLHttpRequest" as IE7 does, but this is a different issue than yours. I guess the error happens during posting to the second URL, because JS error happens there, can you investigate the second page or post its html/js code? <html> <head> <script> function test() { ajax(['para1', 'para2']); } function ajax(parArr, callback) { var http = new XMLHttpRequest(); var params = ""; for (var i=0; i<(parArr.length-1); i++) { params = params + parArr[i]+"&"; } params = params + parArr[parArr.length-1]; http.open("POST", "hello2.html", true); http.setRequestHeader("Content-type", "application/x-www-form-urlencoded"); http.setRequestHeader("Content-length", params.length); http.setRequestHeader("Connection", "close"); http.onreadystatechange = function() {//Call a function when the state changes. if(http.readyState == 4 && http.status == 200) { this.callbackFunction(http.responseText); } } this.callbackFunction = callback || function () { alert("Missing callback function!")}; http.send(params); } </script> </head> <body> <input id='myButton' type=button value='ana hena' onclick='test()'><br> </body> </html> ________________________________ From: "sli...@re..." <sli...@re...> To: htm...@li... Sent: Sunday, February 8, 2009 11:17:43 PM Subject: [Htmlunit-user] (no subject) Hi I have just started using HtmlUnit and have found it excellent so far. I have come across a problem that I hope someone might be able to help me out with. I searched the archives and the web and have not had any luck. The actual error may be from the rhino libraries but I thought I would try here first in case it was something I was doing wrong with HtmlUnit. The stack trace is as follows (the code that generates it is down further) Exception in thread "HtmlUnit Managed Thread #6 for WebWindow : XMLHttpRequest.send" org.mozilla.javascript.EcmaError: TypeError: Cannot find default value for object. (script in http://webhost/Reporter/ from (13, 32) to (106, 10)#38) at org.mozilla.javascript.ScriptRuntime.constructError(ScriptRuntime.java:3654) at org.mozilla.javascript.ScriptRuntime.constructError(ScriptRuntime.java:3632) at org.mozilla.javascript.ScriptRuntime.typeError(ScriptRuntime.java:3660) at org.mozilla.javascript.ScriptRuntime.typeError1(ScriptRuntime.java:3672) at org.mozilla.javascript.ScriptableObject.getDefaultValue(ScriptableObject.java:780) at org.mozilla.javascript.ScriptableObject.getDefaultValue(ScriptableObject.java:699) at org.mozilla.javascript.ScriptRuntime.toString(ScriptRuntime.java:724) at org.mozilla.javascript.ScriptRuntime.notFunctionError(ScriptRuntime.java:3741) at org.mozilla.javascript.ScriptRuntime.getPropFunctionAndThisHelper(ScriptRuntime.java:2247) at org.mozilla.javascript.ScriptRuntime.getPropFunctionAndThis(ScriptRuntime.java:2214) at org.mozilla.javascript.Interpreter.interpretLoop(Interpreter.java:3143) at script(script in http://webhost/Reporter/ from (13, 32) to (106, 10):38) at org.mozilla.javascript.Interpreter.interpret(Interpreter.java:2487) at org.mozilla.javascript.InterpretedFunction.call(InterpretedFunction.java:164) at org.mozilla.javascript.ContextFactory.doTopCall(ContextFactory.java:398) at com.gargoylesoftware.htmlunit.javascript.HtmlUnitContextFactory.doTopCall(HtmlUnitContextFactory.java:192) at org.mozilla.javascript.ScriptRuntime.doTopCall(ScriptRuntime.java:3065) at org.mozilla.javascript.InterpretedFunction.call(InterpretedFunction.java:162) at com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine.callFunction(JavaScriptEngine.java:472) at com.gargoylesoftware.htmlunit.javascript.host.XMLHttpRequest.setState(XMLHttpRequest.java:142) at com.gargoylesoftware.htmlunit.javascript.host.XMLHttpRequest.doSend(XMLHttpRequest.java:413) at com.gargoylesoftware.htmlunit.javascript.host.XMLHttpRequest.access$000(XMLHttpRequest.java:54) at com.gargoylesoftware.htmlunit.javascript.host.XMLHttpRequest$1.run(XMLHttpRequest.java:361) at org.mozilla.javascript.Context.call(Context.java:515) at org.mozilla.javascript.ContextFactory.call(ContextFactory.java:507) at com.gargoylesoftware.htmlunit.javascript.host.XMLHttpRequest$2.run(XMLHttpRequest.java:367) at java.lang.Thread.run(Unknown Source) at com.gargoylesoftware.htmlunit.ThreadManager$1.run(ThreadManager.java:116) The javascript on the page that triggers the error is as follows Obviously parArr is an array of parameters and callback is the name of the function that will be called when the ajax request returns. createXMLHttpRequest() returns a browser compatible Ajax object which in this case should be XMLHttpRequest. function ajax(parArr, callback) { var http = createXMLHttpRequest(); var params = ""; for (var i=0; i<(parArr.length-1); i++) { params = params + parArr[i]+"&"; } params = params + parArr[parArr.length-1]; http.open("POST", "/Reporter/", true); http.setRequestHeader("Content-type", "application/x-www-form-urlencoded"); http.setRequestHeader("Content-length", params.length); http.setRequestHeader("Connection", "close"); http.onreadystatechange = function() {//Call a function when the state changes. if(http.readyState == 4 && http.status == 200) { this.callbackFunction(http.responseText); } } this.callbackFunction = callback || function () { alert("Missing callback function!")}; http.send(params); } >From what I can determine the ampersand in the parameters is causing the problem, when I modify the request to pass only one parameter (e.g. no ampersand) it is successful. Any help or hints would be most appreciated. I hope I have provided enough information. Thanks ------------------------------------------------------------------------------ Create and Deploy Rich Internet Apps outside the browser with Adobe(R)AIR(TM) software. With Adobe AIR, Ajax developers can use existing skills and code to build responsive, highly engaging applications that combine the power of local resources and data with the reach of the web. Download the Adobe AIR SDK and Ajax docs to start building applications today-http://p.sf.net/sfu/adobe-com _______________________________________________ Htmlunit-user mailing list Htm...@li... https://lists.sourceforge.net/lists/listinfo/htmlunit-user |