Domanda

I have a problem on CRM javascript when calling a webservice from browsers other than IE. See my code below for the web service call implementation.

function RetrieveMultipleEntity(targetEntity, conditionAttributeName, conditionAttributeValue, targetId, targetAttribute)
{
// Prepare variables to retrieve the contacts.
var authenticationHeader = GenerateAuthenticationHeader();

// Prepare the SOAP message.
// var xml = (the SOAP message)

var xHReq = new ActiveXObject("Msxml2.XMLHTTP");

xHReq.Open("POST", "/mscrmservices/2007/CrmService.asmx", false);
xHReq.setRequestHeader("SOAPAction","http://schemas.microsoft.com/crm/2007/WebServices/RetrieveMultiple");
xHReq.setRequestHeader("Content-Type", "text/xml; charset=utf-8");
xHReq.setRequestHeader("Content-Length", xml.length);
xHReq.send(xml);
// Capture the result.
var resultXml = xHReq.responseXML;

return resultXml;
}

There's a problem on this line:

var xHReq = new ActiveXObject("Msxml2.XMLHTTP");

It runs correctly on IE because it can use ActiveXObject but unfortunately it fails on Firefox/Chrome. I'm looking for suggestions on an alternative of calling the web service. Can anyone help me? Thanks!

È stato utile?

Soluzione

try with

var xHReq = new XMLHttpRequest();

it works also for IE7+

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top