Hello my dear developers,
I have this big issue and, after many trials, I m not able to find an answer yet !
Issue is about calling SharePoint 2010 search.asmx service from javascript code (using xmlHttpRequest and response)
Two thousand billion dollars for you, if you make this code working : ///
After I click on the link, no results are shown in the alert window. Please help me !
______________________________________________________________
<script>
function RetrieveSearchData()
{
//get the request object
var requestObject = new XMLHttpRequest();
//Initializes request and specifies the method, URL, and other information for the request.
requestObject.open("POST", "http://mysitecollection.domain:77/_vti_bin/search.asmx", false);
//set request header
requestObject.setRequestHeader("Content-Type", "text/xml; charset=utf-8");
var packet = "<?xml version='1.0' encoding='utf-8'?><soap:Envelope xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xmlns:xsd='http://www.w3.org/2001/XMLSchema' xmlns:soap='http://schemas.xmlsoap.org/soap/envelope/'><soap:Body><QueryEx xmlns="<queryxml><querypacket">http://microsoft.com/webservices/OfficeServer/QueryService"><queryXml><QueryPacket</querypacket"></queryxml> Revision=\"1000\"><Query><Context><QueryText type=\"STRING\">(contentsource:\"MYCONTENTSOURCE\")</QueryText></Context><SupportedFormats Format=\"urn:Microsoft.Search.Response.Document.Document\"/><ResultProvider>FASTSearch</ResultProvider><Range><StartAt>1</StartAt><Count>20</Count></Range><EnableStemming>true</EnableStemming><EnableSpellCheck>Suggest</EnableSpellCheck><IncludeSpecialTermsResults>true</IncludeSpecialTermsResults><IncludeRelevantResults>true</IncludeRelevantResults><ImplicitAndBehavior>true</ImplicitAndBehavior><TrimDuplicates>true</TrimDuplicates><Properties><Property name=\"IsDocument\"/><Property name=\"Url\" /><Property name=\"FileExtension\"/></Properties></Query></QueryPacket></queryXml></QueryEx></soap:Body></soap:Envelope>";
//Sends an HTTP request to the server and receives a response
requestObject.send(packet);
//process responseXML
alert(requestObject.responseText);
}
</script>
<a onclick="RetrieveSearchData()" href="#">SEARCH</a>
_____________________________________________________________
My best regards !!
Gae