From: Sling G. <sli...@re...> - 2009-02-12 10:47:51
|
Hi Ahmed Using htmlunit-2.5-SNAPSHOT.jar worked with no errors. I will test in my real world tests and advise if that resolves it. I am still using the 2.4 core-js package, should I be using a later version of that as well? Thanks for your help! Sling > Dear Sling, > > Strangely, no errors from SVN version!! > > Please use latest snapshot from http://build.canoo.com/htmlunit/artifacts, > and advise. > > Yours, > Ahmed > > ________________________________ > From: Sling Gatsby <sli...@re...> > To: htm...@li... > Sent: Thursday, February 12, 2009 12:13:14 PM > Subject: Re: [Htmlunit-user] Ajax javascript errors > > Hi > > Sorry for the delay. Below is a simple class and html file that gives me > the error I described. You can set the url for the post to anything it > fails before the request is sent. > > I hope this is enough info. > > TestCase.class > ----------------------------------------- > package junittests; > > import java.net.URL; > > import org.junit.Test; > > import com.gargoylesoftware.htmlunit.HttpMethod; > import com.gargoylesoftware.htmlunit.WebRequestSettings; > import com.gargoylesoftware.htmlunit.html.HtmlPage; > > public class TestCase { > > @Test > public void test() { > try { > WebRequestSettings reqSet = new WebRequestSettings(new URL( > "http://localhost/test.html"), HttpMethod.POST); > HtmlPage page = ReporterTestHelper.webClient.getPage(reqSet); > Thread.sleep(5 * 1000); > > System.err.println(page.getWebResponse().getContentAsString()); > } catch (Exception e) { > e.printStackTrace(); > } > > } > > } > ----------------------------------------- > > test.html > ----------------------------------------- > <html> > <head> > <title>Test Case</title> > <script type="text/javascript"> > > > function createXMLHttpRequest() { > if (typeof XMLHttpRequest != "undefined") { > return new XMLHttpRequest(); > } else if (typeof ActiveXObject != "undefined") { > return new ActiveXObject("Microsoft.XMLHTTP"); > } else { > throw new Error("XMLHttpRequest not supported"); > } > } > > 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", "/test.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); > } > > function getObjectByID(elmID) { > if(document.getElementById) {elmID = document.getElementById(elmID);} > else if(document.all) {elmID = document..all[elmID];} > else if(document.layers) {elmID = this._getLayer(elmID);} > else if(document.forms) { > if(document.forms[elmID]) {elmID = document.forms[elmID];} > else { > for(var i=0; i<document.forms.length; i++) { > if(document.forms[i][elmID]) { > elmID = document.forms[i][elmID]; > break; > } > } > } > } > else {elmID = null;} > return elmID; > } > > function callback(data){ > var obj = getObjectByID('testbtn'); > obj.disabled=false; > } > > ajax(['ACTION=99','TEST=22'], callback); > </script> > </head> > <body> > Test Case<br /> > <button disabled="true" id="testbtn">Get It</button> > </body> > </html> > ----------------------------------------- > > Thanks > > Sling > > > ------------------------------------------------------------------------------ > 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 > |