BUG Community

Welcome! Log In

Forums Applications AJAX and the IWSRespone class

Subscribe to AJAX and the IWSRespone class  4 posts, 3 voices

Log in to reply to this topic
Jan 29, 2009 4:14pm
Img_missing_medium Kabada 13 posts

I'm currently working on a little web interface for an app I wrote, and I want it to use Ajax to get the status of my application.

Without Ajax it works perfectly fine. I use com.buglabs.services.ws.IWSResponse to create a little web page with all the status info.

This might just be my lack of experience with Ajax, but is there a way to get IWSResponse to react to my Ajax requests? The code below works with foo.php pages, but IWSResponse won't react to it.

function statusRequest(){
var ajaxRequest;

// Opera 8.0+, Firefox, Safari
ajaxRequest = new XMLHttpRequest();
} catch (e){
// Internet Explorer
ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP");
} catch (e) {
ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP");
} catch (e){
return false;
ajaxRequest.onreadystatechange = function(){
if(ajaxRequest.readyState == 4){
document.myForm.motionstatus.value = ajaxRequest.responseText;
ajaxRequest.open("GET", "", true);
Jan 30, 2009 4:42pm
Medium Bug Labs team bballantine 56 posts

Hi Kabada – I’m not the only BUG employee, but for some reason I seem to be the first to come across your questions…

I’m have not used the IWSResponse. Every time I create a web service, I use a custom servlet. This application, I think, is a good place to learn how to do that—http://buglabs.net/applications/SimpleServlet . Hopefully one of my colleagues that is more familiar with IWSResponse can chime in, though.

In the meantime, have you successfully been able to hit that url by plugging it into a browser? Also, a command line tool called curl is super-useful for debugging web services. Is the page containing the ajax client code stuff served from I know that browsers may block asynchronous requests from pages originating from a different IP for security reasons.

Those are my first ideas. If anyone else sees this and wants to chime in, please do.

Jan 30, 2009 5:24pm
Medium Bug Labs team akweon 2 posts

Hi Kabada,
I think bballantine pointed you in the right direction. You’ll need to create a proxy php page to access your BUG web service because ajax requests are only allowed from the same host.

This article contains a sample proxy page code you can probably use:

Or you can google "php proxy page ajax" and look at other examples.

Hope it helps!

Feb 2, 2009 12:31pm
Img_missing_medium Kabada 13 posts

Thx, I wrote a proxy and it works.
Only ever used Ajax on the home webserver before :)

Log in to reply to this topic
Forums Applications AJAX and the IWSRespone class

Powered by Community Engine