www.webOShelp.net

Get the latest on:webOS Developers' RSS FeedwebOS Facebook page webOS Twitter Feed

Home Forums

The www.webOShelp.net WebOS / Mojo Developers' Forum

WebOS Mojo Development => Mojo Newbies => Topic started by: ctownj30 on August 29, 2010, 08:04:50 AM



Title: Simple XMLHttpRequest problem
Post by: ctownj30 on August 29, 2010, 08:04:50 AM
Been beating my head against XMLHttpRequest for a long time.  I've boiled this down to the simplest possible request:

Code:
xhReq.open("GET", "https://ajaxify.com/run/xmlHtttpRequestCall/sumGet.phtml?figure1=5&figure2=10", false);
xhReq.send(null);
  var serverResponse = xhReq.responseText;
this.controller.get("testoutput").update(serverResponse);

I've know calls are supposed to be asyncronous but I've tried that route too to no avail.

Why doesnt the above call work?  What I really want to do is much more complex, but I cannot get any response out of XMLHttpRequest in any way (outputting statustext, reponse, anything...)

Thanks - djm


Title: Re: Simple XMLHttpRequest problem
Post by: semprance on September 04, 2010, 03:41:27 AM
I've been having problems getting AJAX working in WebOS too.

Calls are asynchronous as standard in WebOS, synchronous simply is not a choice. You need to assign a function to xhr.onreadystatechange and inside the function have it only run when xhr.readyState == 4. (You might want to check the exact syntax, I'm writing this from memory.

I've tried using Ajax.Request a number of times but it just seems to throw vague errors and never even gets a change in readyState so I've given up and started writing my own wrapper for XMLHttpRequest instead.

Good luck.