I believe you know ajax function whichever in server and on client, whatever programing languages.
Therefore I just show you a sample code first.
Case study:
table name: ftest
require columns: ftest_jt_id, ftest_name, ftest_age, ftest_ave
api name: ‘js10’
IN: {“apino”:”js10″,”subquery”:”[‘age’:{age}]”}
OUT: {“result”:true or false, “Jetelina”:”[{“ftest_jt_id”:”{ftest_jt_id}”,”ftest_name”:”{ftest_name}”,”ftest_age”:”{ftest_age}”,”ftest_ave”:”{ftest_ave}”,”message from Jetelina”:””…..””}
execution sql: select ftest.ftest_jt_id,ftest.ftest_name,ftest.ftest_age,ftest.ftest_ave from ftest as ftest where ftest.ftest_age < {age};
hum, looks like a little bit strange in Json, but do not care, I work correctly.
const getAjaxData = (s) => {
let pd = {};
pd["apino"] = "js10";
pd["subquery"] = "['age':30]";
let dd = JSON.stringify(pd);
let url = "http://localhost:8000/apiactions"
$.ajax( {
url: url,
type: "post",
data: dd,
contentType: 'application/json',
dataType: "json",
}).done(function(result, textStatus, jqXHR) {
}).fail( function( result ){
}).always(function(result){
});
}
You know ‘apiactions’ is the callable webapi name, you throw your Json form of api forward to this webapi.
Indeed, this webapi has alternative name; ‘plzjetelina’ and ‘executionapi’, work as same as ‘apiactions’.