Getting an Ajax error

Hello

Making progress, but getting the following error in the log

http://localhost:8080 is not allowed by Access-Control-Allow-Origin., line 1:

XMLHttpRequest cannot load http://172.27.11.83/MobilityServices70/Login.svc/json/GetUserContext. Origin http://localhost:8080 is not allowed by Access-Control-Allow-Origin

I'm pointing to the local web server and followed all the instructions I could find.  I'm trying to run this on windows mobile 6.5.

Thanks

John

Anonymous (not verified)
The problem lies on your

The problem lies on your remote web server (172.27.11.83). You will need to change the headers of the webserver to allow cross domain HTTP requests. This can be done by adding this line to the HTTP headers:

Access-Control-Allow-Origin: *

This will allow the response from the server to be read by any client. You can restrict the permissions to a set of domains if you wish to increase security. This stackoverflow answer seems useful in this case:

http://stackoverflow.com/questions/1653308/access-control-allow-origin-multiple-origin-domains

I hope this helps

Vote: 
Vote up!
Vote down!

Points: 0

You voted ‘up’


John Barnes
BenThanks for the response. 

Ben

Thanks for the response.  I've added Access-Control-Allow-Origin to global.asax in out wcf rest service.  But it doesn't even seem to be calling the service.  We are able to access the service from firefox.  I don't know if the problem has anything to do with ActiveXObject("Microsoft.XMLHTTP") since I'm trying to run on window mobile 6.5.  I don't know if there is a setting in config.xml that I'm missing.

Thanks for the help

John

Vote: 
Vote up!
Vote down!

Points: 0

You voted ‘up’


Robert Galvin
JohnTry setting the following

John

Try setting the following in the config file:

Our legacy support for “active” is most likely causing the confusion. Disabling loading the legacy modules should help you.

Vote: 
Vote up!
Vote down!

Points: 0

You voted ‘up’


John Barnes
RobThanks for the response. 

Rob

Thanks for the response.  I did try the following

<NPAPI>

        <NPAPIDirectory value="file://%INSTALLDIR%\NPAPI\"/>

        <Preloads>

          <PreloadLegacyGeneric value="0"/>

          <PreloadLegacyODAX    value="0"/>

          <PreloadLegacyNoSIP   value="0"/>

          <PreloadLegacyAirBeam value="0"/>

          <PreloadLegacyAPD     value="0"/>

          <PreloadJSObjects     value="0"/>

        </Preloads>

      </NPAPI>

Also I tried renaming legacy dll, none of this helped.

John

Vote: 
Vote up!
Vote down!

Points: 0

You voted ‘up’


Robert Galvin
Not sure if it matters, but

Not sure if it matters, but PreloadJSObjects should be 1 not 0

After making that change load the attached test page, It should put an alert that says ‘false’. If it says false, then you have turned off the legacy ActiveX object. If it says true, then double check you are loading the changed config file and possibly restart the device and retry. What version of RE are you using? Also, are you using jQuery or other Js libraries/frameworks?

Vote: 
Vote up!
Vote down!

Points: 0

You voted ‘up’


John Barnes
RobAgain thanks for the

Rob

Again thanks for the response.  When I set the legacy to 0 I get a false and when I set it to 1 I get a true.  I'm using version 1.0.2.3 of RE.  We are using JQuery and JQuery Mobile for the application.

Motorola just dropped off a ET1 so that is the next unit I will try it on.

John

Vote: 
Vote up!
Vote down!

Points: 0

You voted ‘up’


Garrick van Sch...
Hi All,Can anyone please

Hi All,

Can anyone please provide sample code for accessing the XMLHttpRequest for RhoeElements? We were able to test our webservice calls from Firefox etc, but the same logic fails when pointing RhoeElements to our remote website.

I would be very grateful if any developers that have been successful in this regard provide some samples.

Garrick

Vote: 
Vote up!
Vote down!

Points: 0

You voted ‘up’


Søren Corneliussen
What type of webserver are

What type of webserver are you using?

Vote: 
Vote up!
Vote down!

Points: 0

You voted ‘up’


Njål Stabell
If you have added the Access

If you have added the

Access-Control-Allow-Origin: *  for the server response and you are using JQM add the following to your HTML document headers:


<script type="text/javascript" charset="utf-8">

  $( document ).bind( "mobileinit", function() {

    $.support.cors                           = true;

    $.mobile.allowCrossDomainPages  = true;

    $.mobile.pushStateEnabled         = false;

  });

</script>

That should sort out your cross domain issues.


Vote: 
Vote up!
Vote down!

Points: 0

You voted ‘up’


Garrick van Sch...
Hi John,I think we had a

Hi John,

I think we had a similar issue. If you are running on the same domain, the ports are still causing the Cross Scripting Error. It looks like you are trying to access a url on port 80 from port 8080. If you control 172.27.11.83 you can add the Access-Control-Allow-Origin indicator to your server. If you do not have access to this server, you will need to make a call to a local resource that can then access the remote resource via a client side script. So you could call a local PHP file that is on the same port as your html page, and the call the remote file via the PHP script which is server side.

Hope this helps,

Garrick

Vote: 
Vote up!
Vote down!

Points: 0

You voted ‘up’


John Barnes
HelloGarrick and all thanks

Hello

Garrick and all thanks for your responses.  Sorry about the delay in responding, but I've been moved to another project.  It didn't seem like there would be much else to try until there was a new release of Rhoelements.  Our problem distills down to this.  If the data type in the ajax call is jsonp it calls our service.  If the data type is jason it doesn't call the service.  So no changes on the service side are going to have any effect.  We can't change all our web service calls to support jsonp because the current calls are working fine with IOS.  I noticed a note from another that was having the same issue.  I will check in from time to time.  I hope the next version of Rhoelements allows jsaon calls.

John

Vote: 
Vote up!
Vote down!

Points: 0

You voted ‘up’


Log in to post comments