API AppML
API AppML xác định các phương thức và thuộc tính của AppML
Các phương thức và thuộc tính có thể làm gì?
Với các phương thức và thuộc tính, bạn có thể:
- Tạo ứng dụng AppML
- Nguồn cấp dữ liệu cho các ứng dụng
- Tìm nạp dữ liệu ứng dụng để sử dụng trong trang web của bạn
Thí dụ
new AppML () tạo một đối tượng AppML mới.
dataSource đặt nguồn dữ liệu của đối tượng AppML.
getData () lấy dữ liệu.
data.records chứa các bản ghi dữ liệu.
Bạn có thể lặp lại các bản ghi và hiển thị nội dung trong một phần tử HTML:
Thí dụ
// Create an AppML object and fetch the data
myObj = new AppML();
myObj.dataSource = "https://www.w3schools.com/appml/customers.php";
myObj.getData();
// Locate the data records
myArr = myObj.data.records;
len = myArr.length;
// Display the records
for (i = 0; i < len; i++) {
txt += myArr[i].CustomerName + "<br>";
}
document.getElementById("demo").innerHTML = txt;
Kết quả
Alfreds Futterkiste
Berglunds snabbköp
Centro comercial Moctezuma
Ernst Handel
FISSA Fabrica Inter. Salchichas S.A.
Galería del
gastrónomo
Island Trading
Königlich Essen
Laughing Bacchus Wine
Cellars
Magazzini Alimentari Riuniti
North/South
Paris spécialités
Rattlesnake Canyon Grocery
Simons bistro
The Big Cheese
Vaffeljernet
Wolski Zajazd
Một số phương pháp AppML
Method | Description |
---|---|
new AppML() | Creates a new AppML object |
run() | Runs an application object |
appml("name") | Returns the appml object with the specified name |
displayMessage(text) | Displays a specified message. |
setError(no, description) | Sets a specified error and error description. |
Một số thuộc tính AppML
Property | Description |
---|---|
appName | The application name (the container id) |
container | The application container element |
controller | The application controller |
data | The application data object |
dataSource | The application data source |
message | The application message |
Một số thuộc tính đối tượng dữ liệu
Property | Description |
---|---|
data.model | The application data model |
data.records | The application data records |