Hello Everyone
I have a Catalog form. A user enters data in the form. When the user clicks on submit, with the use of Javascript, using the information of just 1 field (a Social ID Number), that data is sent to a JSON url. Then the matching data is returned and needs to fill one field with the returning data (Would be an older person ID). Hope that makes sense in what I am trying to do.
In a nutshell, will be sending 1 field with the persons existing ID number eg: 12345, then that number: "12345" will be sent to the JSON address, then using the "12345" it will find a match because no two ID numbers are the same. Then with the matching data, only the old ID number needs to be populated in 1 field on the form.
How could I go about this please ? I have been reading upon JSON and Javascript and taking in as much as I can. Please see below what I have so far.
What I have tried:
function findpersonID() {
var xhr = new XMLHttpRequest();
var url = "http://testurl.com:38080/findpersonID";
xhr.open("POST", url, true);
xhr.setRequestHeader("Content-type", "application/json");
xhr.onreadystatechange = function () {
if (xhr.readyState == 4 && xhr.status == 200) {
var json = JSON.parse(xhr.responseText);
for (var i = 0; i < json.responseObjects.length; i++) {
}
return json
}
}
var lidNumber = serviceForm.TEST_Form.IDNumber.getValue()[0];
var personSearchJsonStr = '{ "typeHint":"person", "idNumber":"' + lidNumber + '"}';
xhr.send(personSearchJsonStr);
return json
serviceForm.TEST_Form.OLDIDNumber.setValue()[0];
}