SettingRead_Ajax + SettingRead_Ajax_IntoObject

Two functions to return an output of file into object on page or back to caller in js, as simple as AJAX can be.
Two original functions found it buried in one of my old website modules also included below (AJAXRead_obj and AJAXRead_fx).
You do not need all 4, you need either SettingRead_Ajax or both SettingRead_Ajax + SettingRead_Ajax_IntoObject
Using XMLHTTP, we might need to update that though.

CodeFunctionName
What is this?

Public

Tested

Original Work
function SettingRead_Ajax_IntoObject(SettingName, ObjectID, Value_or_innerHTML) {
    // Reads settingname back into an Object with id = ObjectID
    // SettingURL already defined
    // Pass Value_or_innerHTML = 1 to set the value of object, 2 to set innerHTML
    // Needs AJAXRead_fx
    var objRett = document.getElementById(ObjectID);
    var SettingURL = "/Assets/SettingRead_ASPFile/?SettingName=";
    if Value_or_innerHTML = 1 {
        objRett.value = SettingRead_Ajax(SettingName) ;
    } else {
        objRett.innerHTML = SettingRead_Ajax(SettingName) ;
    }
}
function SettingRead_Ajax(SettingName) {
    // Used in Account113 to read certian setting value from a setting name
    var SettingURL = "/Assets/SettingRead_ASPFile/?SettingName=" + SettingName ;
    var Rett = "N/A";
    if (window.XMLHttpRequest) { // code for IE7+, Firefox, Chrome, Opera, Safari
        xmlhttp = new XMLHttpRequest();
        }
    else { // code for IE6, IE5
        xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
        }
    xmlhttp.open("GET", SettingURL ,false);
    xmlhttp.send();
    Rett = xmlhttp.responseText;
    return Rett;
}







// Original older version    ==============================================
// ================================================================
function AJAXRead_obj(htmlurl, objid) {
    // htmlurl is the full path to the ASP file that does the reading
    // objid is the object to read that file in
var toobj=document.getElementById(objid);
toobj.innerHTML = "Reading ...";
    if (window.XMLHttpRequest) {// code for IE7+, Firefox, Chrome, Opera, Safari
        xmlhttp=new XMLHttpRequest();
        }
    else {// code for IE6, IE5
        xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
        }
    xmlhttp.onreadystatechange=function() {
        if (xmlhttp.readyState==4 && xmlhttp.status==200) {
            toobj.innerHTML=xmlhttp.responseText;
        }
    }
    xmlhttp.open("GET", htmlurl , true);
    xmlhttp.send();
}
function AJAXRead_fx(htmlurl) {
    // htmlurl is the full path to the ASP file that does the reading
    //
    var rett = "Reading ...";
    if (window.XMLHttpRequest) {// code for IE7+, Firefox, Chrome, Opera, Safari
        xmlhttp=new XMLHttpRequest();
        }
    else {// code for IE6, IE5
        xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
        }
    xmlhttp.open("GET", htmlurl ,false);
    xmlhttp.send();
    rett = xmlhttp.responseText;
    return rett;
}

SettingName, ObjectID, Value_or_innerHTML
SettingName
And
htmlurl
htmlurl, objid

Views 191

Downloads 67

CodeID
DB ID