Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
T
technobel.sf
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
mathieu
technobel.sf
Commits
b4fdb2b2
Commit
b4fdb2b2
authored
May 15, 2018
by
Mat
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
la fonction ajax, commentée et finalisée
parent
515e5ae4
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
22 additions
and
5 deletions
+22
-5
src/TechnoBundle/Resources/views/Ajax/Owner/mainDisplay.html.twig
...noBundle/Resources/views/Ajax/Owner/mainDisplay.html.twig
+22
-5
No files found.
src/TechnoBundle/Resources/views/Ajax/Owner/mainDisplay.html.twig
View file @
b4fdb2b2
...
...
@@ -18,18 +18,24 @@
{%
block
customJS
%}
<script
type=
"text/javascript"
>
// L'URL de l'API
let
ownersURL
=
'
{{
path
(
'api_owner_read'
)
}}
'
;
// Le tableau
let
table
=
document
.
querySelector
(
"
table#table-owners
"
);
let
tbody
=
table
.
querySelector
(
"
tbody
"
);
console
.
log
(
ownersURL
);
console
.
log
(
table
);
//
console.log(ownersURL);
//
console.log(table);
// La fonction AJAX
function
reloadTableOwner
()
{
let
xhr
=
new
XMLHttpRequest
();
xhr
.
onreadystatechange
=
function
()
{
console
.
log
(
this
);
//console.log(this);
if
(
this
.
readyState
===
4
&&
(
this
.
status
===
200
||
this
.
status
===
0
))
{
...
...
@@ -38,26 +44,37 @@
for
(
let
i
=
0
;
i
<
json
.
length
;
i
++
)
{
let
tr
=
document
.
createElement
(
'
tr
'
);
let
td1
=
document
.
createElement
(
'
td
'
);
td1
.
textContent
=
json
[
i
].
firstname
;
tr
.
appendChild
(
td1
);
let
td2
=
document
.
createElement
(
'
td
'
);
td2
.
textContent
=
json
[
i
].
lastname
;
tr
.
appendChild
(
td2
);
let
td3
=
document
.
createElement
(
'
td
'
);
td3
.
textContent
=
json
[
i
].
created_at
;
tr
.
appendChild
(
td3
);
let
td4
=
document
.
createElement
(
'
td
'
);
td4
.
textContent
=
json
[
i
].
modify_at
;
td4
.
innerHTML
=
'
<a class="btn btn-primary" href="#"><i class="fas fa-edit fa-fw"></i> Editer</a>
'
+
'
<a class="btn btn-danger" href="#"><i class="fas fa-trash fa-fw"></i> Supprimer</a>
'
;
tr
.
appendChild
(
td4
);
tbody
.
appendChild
(
tr
);
console
.
log
(
json
[
i
].
firstname
);
}
console
.
log
(
json
);
}
};
xhr
.
open
(
'
GET
'
,
ownersURL
,
true
);
// les données GET sont dans ownersURL
xhr
.
send
(
null
);
// les données POST seraient ici
}
// dans la console JS, recharger la fonction suivante pour voir apparaitre le debug Ajax de Symfony
reloadTableOwner
();
</script>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment