Ajax executes Domino agent and returns data (Get method)

Source: Internet
Author: User

using the original Ajax to invoke Domino's proxy is one of the simplest Ajax, of course, with jquery as well.

var xmlrole=new xmlhttpobject ("Get", "/filename/database name. nsf/proxy name? openagent&key=" +math.random (), False, ""); If it's not written, an agent executes once in session, giving a random number to avoid caching problems or timestamp
Xmlrole.senddata ();
var xmlresponse = Xmlrole.gettext (); Xmlresponse data for the background agent print


function Xmlhttpobject (method,url,syne,channel) {
/*
Function Description: Common operation XMLHttpRequest Object, and encapsulate it
Function call: Format: var xmlusersetting=new xmlhttpobject ("Get", Url,false, "Personal Workbench")
Xmlusersetting.senddata ();
Gets the textual content of the XML document: Xmlusersetting.gettext ();
Function parameters: The way method-sends the request [Post/get/put/propfind]; url-sends the URL of the request;
syne-synchronous or asynchronous mode [true/false];channel-current channel name, NOT null;

*/
var xmlhttp=null
var o=this
This.url=url
This. Syne=syne
This.method=method.touppercase (); Force method to uppercase
This.senddata = function ()
{

Create a XMLHttpRequest Object
if (window. XMLHttpRequest) {//To determine whether to implement XMLHttpRequest as a local JavaScript object
XMLHttp = new XMLHttpRequest (); Create an instance of the XMLHttpRequest (local JavaScript object)
}else if (window. ActiveXObject) {//Determine if ActiveX controls are supported
XMLHttp = new ActiveXObject ("Microsoft.XMLHTTP");//Create a XMLHttpRequest object by instantiating a new instance of ActiveXObject
}
With (XMLHttp) {
Open (' Get ', This.url, this. Syne);
onreadystatechange = O.processrequest;
Send (NULL);
}
}


This. Processrequest=function ()
{
if (xmlhttp.readystate = = 4) {//Judge object state
if (Xmlhttp.status = = 200) {//information has been successfully returned to start processing information
The operation after the XML has been successfully loaded [this method is not used yet]
}
}
}


This.gettext=function ()
{
if (xmlhttp==null) {return "the page you are requesting has an exception, try again. "}
if (xmlhttp.readystate = = 4) {//Judge object state
if (Xmlhttp.status = = 200) {//information has been successfully returned to start processing information
Break out the contents of the <body></body>
var xmlrestext = Xmlhttp.responsetext;
var L = xmlrestext.indexof ("<body");
L = Xmlrestext.indexof (">", L);
var r = xmlrestext.indexof ("</body>", L);
Xmlrestext = xmlrestext.substring (l+2,r-1);

Return Xmlrestext
}

}
Return xmlhttp.readystate
}
}

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.