class User {
constructor ({name, age}) {
this.name = name
this.age = age
}
greet() {
console.log(`Hi! I'm ${this.name}`)
}
}
const alex = new User({name: 'Alex', age: 18})
alex.greet() // <- Optional request
class User {
constructor ({name, age, roles}) {
this.name = name
this.age = age
this.hasAccess = null
this.setRoles(roles) // <- Require request
}
setRoles(roles) {
if (roles.access) {
this.hasAccess = true
} else {
this.hasAccess = false
}
}
greet() {
console.log(`Hi! I'm ${this.name}`)
return this
}
}
const alex = new User({name: 'Alex', age: 18, roles: {access: true}})
alex.setRoles({access: false}) // <- Optional request
<a class="my_button" href="actions.php?action=create_user&number=1">Создать пользователя</a>
$.ajax({
url: 'actions.php',
method: 'POST',
data: {
'action': 'create_user'
})
$_GET['action']
$_GET['number']
data-
атрибуты нужны на клиенте, чтобы удобно передавать какае-то данные внутри html элемента:<a class="my_button" data-action="create_user" data-number="1">Создать пользователя</a>
console.log(
document.querySelector('.my_button').dataset
)
{
"action":"create_user",
"number":"1"
}
[
{id: 'prod1', count: 1, price: 100, name: 'Prod 1'},
{id: 'prod2', count: 1, price: 200, name: 'Prod 2'},
{id: 'prod3', count: 1, price: 300, name: 'Prod 3'},
]
var Arrays = [
{id:'order', count: 1, price: 300, name: 'Order Price'}
]