11 Replies Latest reply on Feb 16, 2012 4:03 PM by John Barnes

    Getting an Ajax error



      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 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.





        • Re: Getting an Ajax error
          Benedict Kennedy

          The problem lies on your remote web server ( 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:




          I hope this helps

            • Re: Getting an Ajax error



              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



                • Re: Getting an Ajax error
                  Robert Galvin



                  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.

                    • Re: Getting an Ajax error



                      Thanks for the response.  I did try the following


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


                                <PreloadLegacyGeneric value="0"/>

                                <PreloadLegacyODAX    value="0"/>

                                <PreloadLegacyNoSIP   value="0"/>

                                <PreloadLegacyAirBeam value="0"/>

                                <PreloadLegacyAPD     value="0"/>

                                <PreloadJSObjects     value="0"/>



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



                        • Re: Getting an Ajax error
                          Robert Galvin

                          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?

                            • Re: Getting an Ajax error



                              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 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.



                    • Re: Getting an Ajax error
                      Njål Stabell

                      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;




                      That should sort out your cross domain issues.

                      • Re: Getting an Ajax error

                        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.



                        • Getting an Ajax error

                          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 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,


                            • Re: Getting an Ajax error



                              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.