I have this function call which I need to convert to POST request because this is getting popped up in query parameter in SSL security threat. Could you please help ? Thanks

 LoadYearMakeModelUsingAutoVin(controlId, 'RequestXml.aspx?name=GetVehicleInfoUsingVinCanada&VinOrSerialNumber=' + vinOrserialnumber);

 ------------------------------------
 function LoadYearMakeModelUsingAutoVin(controlItem, dataSourceUrl) {
    var xmlDoc;
    var xmlDoc2;
    if (window.ActiveXObject) {
        var xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
        xmlHttp.open("POST", dataSourceUrl, false);

        xmlHttp.send(null);
        xmlDoc = new ActiveXObject("Microsoft.XMLDOM");
        xmlDoc.async = false;
        xmlDoc = xmlHttp.responseXML;
        var nodes = xmlDoc.getElementsByTagName("LookupData");
        if (nodes.length > 0) {
            var node = nodes.item(0);
            if (node.childNodes.item(0).text != null) {
                if (node.childNodes.item(0).text.split("`").length == "9") {
                    FillAutoInfoValuesCanada(node, controlItem);
                }
                else {
                    BlankAutoInfoValues(controlItem); //Defect 57092
                }
            }
        }
        else {
            BlankAutoInfoValues(controlItem);
        }
    }
    else if (window.XMLHttpRequest) {
        var xmlHttp2 = new XMLHttpRequest();
        xmlHttp2.open("GET", dataSourceUrl, false);
        xmlHttp2.send(null);
        xmlDoc2 = xmlHttp2.responseXML;
        var nodes = xmlDoc2.getElementsByTagName("LookupData");
        if (nodes.length > 0) {
            var node = nodes.item(0);
            if (node.childNodes.item(0).text != null) {
                if (node.childNodes.item(0).text.split("`").length == "6") {
                    FillAutoInfoValuesCanada(node, controlItem);
                }
                else {
                    BlankAutoInfoValues(controlItem);
                }
            }
        }
    }
    else {
        alert('Your browser does not support some functionality required by this page. To continue please upgrade to the latest release of your browser software.');
        return;
    }
}

You can just take apart the URL page and the params, like this:

function LoadYearMakeModelUsingAutoVin(controlItem, dataSourceUrl, postParams) {
    ...

    var xmlHttp2 = new XMLHttpRequest();
    xmlHttp2.open("POST", dataSourceUrl, false);

    //Set proper header data
    http.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
    http.setRequestHeader("Content-length", postParams.length);
    http.setRequestHeader("Connection", "close");

    xmlHttp2.send(postParams);

    ...

}

//And use it like
LoadYearMakeModelUsingAutoVin(controlId, 'RequestXml.aspx', 'name=GetVehicleInfoUsingVinCanada&VinOrSerialNumber=' + vinOrserialnumber);

Or you could use FormData also:
https://developer.mozilla.org/en-US/docs/Web/API/FormData/Using_FormData_Objects

This works, I was not able to set header data. Thanks much :)

You're welcome.
Just mark the thread as solved please. You can create a new one if you need futher assistence.

Cheers!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.