Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ajax problems? with activexobjects

Tags:

ajax

php

activex

I keep getting the following error's:

uncaught exception: [Exception... "Component returned failure code: 0x80004005 (NS_ERROR_FAILURE) [nsIXMLHttpRequest.send]" nsresult: "0x80004005 (NS_ERROR_FAILURE)" location: "JS frame :: http://site/cms/js/interface.js :: doAjaxCall :: line 300" data: no]

 

uncaught exception: [Exception... "Component returned failure code: 0x80004005 (NS_ERROR_FAILURE) [nsIXMLHttpRequest.send]" nsresult: "0x80004005 (NS_ERROR_FAILURE)" location: "JS frame :: http://site/cms/js/interface.js :: doAjaxCall :: line 300" data: no]

Line 0

This is the function with the doAjaxCall

function doAjaxCall(cmd,params) {
  var postdata='cmd='+cmd+'&params='+params;

  var a=sajax_init_object();
  if (a) {
    a.open("POST","ajax_handler.php", false);
    a.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
    a.send(postdata);                      <====Line 300
      document.body.style.cursor="default";

    if(a.readyState == 4) {
      return a.responseText;
    } else {
      alert("We where unable to execute the ajax call.");
    }
  }

function sajax_init_object() {
    var A;
    try {
        A=new ActiveXObject("Msxml2.XMLHTTP");
    } catch (e) {
        try {
            A=new ActiveXObject("Microsoft.XMLHTTP");
        } catch (oc) {
            A=null;
        }
    }
    if(!A && typeof XMLHttpRequest != "undefined")
        A=new XMLHttpRequest();
    if (!A)
        alert("Could not create connection object.");
    return A;
}

Any idea's?

like image 678
sanders Avatar asked Nov 15 '22 16:11

sanders


1 Answers

Due to security restrictions in Javascript, it is not possible to retrieve information from remote domains via an XMLHttpRequest. I think you need a proxy!

like image 127
piero Avatar answered Dec 18 '22 01:12

piero