+getJsonData
This commit is contained in:
@ -1,5 +1,5 @@
|
||||
//var ScriptName='../api/dbms/v09/records.xyz'; //POST
|
||||
//var ScriptDName='../download';
|
||||
//var ScriptUName='../upload';
|
||||
//var ScriptRName='../reports'; //GET For download reports (?file=name)
|
||||
//var ScriptRName='/api/dbms/v09/reports'; //GET For download reports (?file=name)
|
||||
//var ScriptSName='../session';
|
||||
|
||||
@ -255,6 +255,20 @@ function loadContent(url,obj)
|
||||
req.send( null );
|
||||
}
|
||||
|
||||
|
||||
function getJsonData(url, callback) {
|
||||
fetch(url)
|
||||
.then(response => {
|
||||
if (!response.ok) {
|
||||
throw new Error("Error HTTP: " + response.status);
|
||||
}
|
||||
return response.json();
|
||||
})
|
||||
.then(data => callback(data))
|
||||
.catch(error => console.error("Fetch error:", error));
|
||||
}
|
||||
|
||||
|
||||
//POST Json Data to server
|
||||
function postJsonData(url,data,fun){
|
||||
if(typeof data !== 'string') {
|
||||
@ -291,6 +305,7 @@ function postJsonData(url,data,fun){
|
||||
req.setRequestHeader("Content-type", "application/json");
|
||||
req.send(data);
|
||||
}
|
||||
|
||||
//POST Json Data to server
|
||||
function postXMLData(url,data,fun){
|
||||
if(typeof data !== 'string') {
|
||||
|
||||
Reference in New Issue
Block a user