API made using PHP to work with FileMaker databases using AJAX calls.
'Users' Table
id | name | age |
---|---|---|
110 | Jade | 20 |
111 | 22 | |
112 | Jay | 27 |
First Row
Return the first row of a table by just passing the API the layout name.
$.ajax({
url: 'api.php',
method: 'post',
data: {
layout: 'Users'
},
success: function (user) {
console.log(user);
}
});
Results
{
id: 110,
name: 'Jade',
age: 20
}
Row By ID
You can return a row that is equal to an ID by passing it both the ID and what field to find it in.
$.ajax({
url: 'api.php',
method: 'post',
data: {
find: 'id',
id: 112,
layout: 'Users'
},
success: function (user) {
console.log(user);
}
});
Results
{
id: 112,
name: 'Jay',
age: 27
}
Adding New Row
Add a new row of information to the end of any layout.
$.ajax({
url: 'api.php',
method: 'post',
data: {
save: true
data: {
layout: 'Users',
id: 113,
name: 'Josh',
age: 25
}
},
success: function (save) {
console.log(save);
}
});
Updating Row By ID
Update a certain entry by passing the API the row and ID to update along with the data.
$.ajax({
url: 'api.php',
method: 'post',
data: {
layout: 'Users',
save: true,
find: 'id',
id: 111,
data: {
name: 'Nick'
}
},
success: function (save) {
console.log(save);
}
});