Click here to Skip to main content
15,899,679 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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];
}
Posted
Comments
Richard Deeming 11-Aug-16 9:48am    
What does the returned JSON look like? (Replace any PII with dummy values if necessary.)
Pu-239 11-Aug-16 9:57am    
Hello Richard, thank you for your response

The JSON from the search URL looks like this:
{
"typeHint":"person",
"firstName":"Jane",
"lastName":"Doe",
"idNumber":"7709224000033",
"passportNumber":null
}

and the JSON from the return URL Looks like this:
{
"typeHint":"person",
"oid": 3902172
}

So in other words I will be sending 'idNumber' in 1 field and hope it matches then I should receive 'oid' in another field. Is this possible ?
MSagar007 22-Aug-16 2:59am    
checkout the below link might can help you

http://www.c-sharpcorner.com/blogs/creating-json-file-and-searching-data-from-json-file-using-javascript

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900