Ticket #1227 (closed bug: invalid)

Opened 5 years ago

Last modified 5 years ago

XHTMLRequest being captured by OpenLayers

Reported by: yancho Owned by: euzuro
Priority: minor Milestone: 2.6 Release
Component: Events Version: 2.0
Keywords: xhtmlrequest, loadURL Cc:
State:

Description

Hi,

I have tried to raise an asynchronous request to a webpage using two different XMLHttpRequest(); and also YAHOO.util.Connect.asyncRequest; (and also loadURL) but all the four requests are being caught by this exception :

try{(this.options['on'+event]||OpenLayers.Ajax.emptyFunction)(transport,json);OpenLayers.Ajax.Responders.dispatch('on'+event,this,transport,json);}catch(e){this.dispatchException(e);}



It is quite strange that none of the two requests are passing through, and I also tried to use OpenLayers.loadURL to give me the same exception.

Below please find the three requests I tried to raise:

Using XMLHttpRequest(); (1)

function openXMLrequest() {
                  var request = false;
                   try {
                     request = new XMLHttpRequest();
                   } catch (trymicrosoft) {
                     try {
                       request = new ActiveXObject("Msxml2.XMLHTTP");
                     } catch (othermicrosoft) {
                       try {
                         request = new ActiveXObject("Microsoft.XMLHTTP");
                       } catch (failed) {
                         request = false;
                       }  
                     }
                   }

           if (request)
             alert("Error initializing XMLHttpRequest!");
                var tid = randomString();
                 var url = "http://localhost/~yancho/xml_parser.php?tid=" + escape(tid);
                 request.open("GET", url, true);
                 request.onreadystatechange = updatePage();
                 request.send(null);
         }

         function updatePage() {
                   alert("Server is done!");
                    }




XHTMLRequest() (2)

      function GetXmlHttpObject(){
            var xmlHttp=null;
            try{
            xmlHttp=new XMLHttpRequest();// Firefox, Opera 8.0+, Safari
            }
            catch (e){
            try{ // Internet Explorer
            xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
            }
            catch (e){
            xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
            }
            }
            return xmlHttp;
            }
       function openXMLrequest() {
                alert ('in Openxmlrequest');
                request2 = new GetXmlHttpObject();

             if (request2) {
             alert ('IN THE IIIIIIIIIIIIIIIIF');
             //if (!request2.fileType)  { request2.fileType = "text"; }
                 alert("IN THE IF");
                    var tid = randomString();
                     var url = "http://localhost/~yancho/xml_parser.php?tid=" + escape(tid);
                     request2.open("GET", url, true);
                     request2.onreadystatechange = updatePage;
                     request2.send(null);
           }
         }

         function updatePage() {
                   alert("Server is done!");
                    }         




YAHOO.util.Connect.asyncRequest()

        var handleSuccess2 = function(){
                    if(x.responseText !== undefined){
               alert("Server is done!");
                   }
          }

        var handleFailure2 = function(){
                if(x.responseText !== undefined){
                     alert("FAILURE!");
                }
        }

          var callback2 =
              {
                success:handleSuccess2,
                failure: handleFailure2
              };
         
           
         
         function openXMLrequest2 () {
           alert ('in openxml2');
           var tid = randomString();
           var url = "http://localhost/~yancho/xml_parser.php?tid=" + escape(tid);
           var x = YAHOO.util.Connect.asyncRequest('GET', url, callback2);


         }     





OpenLayers.loadURL

        var handleSuccess2 = function(){
               alert("Server is done!");
            }

        var handleFailure2 = function(){
                     alert("FAILURE!");
        }

var tid = randomString();
var url = "http://localhost/~yancho/xml_parser.php?tid=" + escape(tid);
OpenLayers.loadURL(url,
                                   null,
                                   null, 
                                   handleSuccess2,
                                   handleFailure2);  




Any help on fixing this problem is extremely appreciated. I have tried to play and check alot my javascript code but many told me there are no bugs in it (and followed tutorials also as how to write an XHTMLRequest()

I also made sure that the first two DO work (in a seperate script) on the same PHP file I am trying to call.

Thanks for your help[[BR]]

Keep up the good work on OpenLayers


Matthew

Change History

Changed 5 years ago by crschmidt

  • state set to Awaiting User Feedback

Changed 5 years ago by crschmidt

  • status changed from new to closed
  • state Awaiting User Feedback deleted
  • resolution set to invalid

This was just a proxyhost problem.

Note: See TracTickets for help on using tickets.