2013-03-26 28 views
1

我從IE瀏覽器以外的其他瀏覽器調用web服務時,出現CRM javascript問題。查看我的代碼以獲取Web服務調用實現。XRM的替代Javascript使用ActiveX調用webservice

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; 
} 

有一個關於此行的一個問題:

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

它正確地運行在IE瀏覽器,因爲它可以使用的ActiveXObject但不幸的是它在Firefox/Chrome的失敗。我正在尋找關於調用Web服務的替代方法的建議。誰能幫我?謝謝!

+0

可能重複[在Safari和Chrome AJAX對象?(http://stackoverflow.com/questions/1697188/ajax-object-在野生動物園和鉻) – Sheepy 2015-04-17 09:59:01

回答

1

嘗試

var xHReq = new XMLHttpRequest(); 

它的工作原理也爲IE7 +