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
7bb59939
Commit
7bb59939
authored
Jul 10, 2018
by
Mat
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
un bouton new pour vider le form
parent
d206c098
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
20 additions
and
31 deletions
+20
-31
0ne/orig/ajax/index4.html
0ne/orig/ajax/index4.html
+20
-31
No files found.
0ne/orig/ajax/index4.html
View file @
7bb59939
...
...
@@ -8,6 +8,7 @@
<body>
<ul
id=
"brasserie"
></ul>
<button
id=
"new"
>
New
</button>
<form
id=
"form"
>
Nom
<input
type=
"text"
name=
"nom"
><br>
Adresse
<input
type=
"text"
name=
"adresse"
><br>
...
...
@@ -19,6 +20,11 @@
$
(
document
).
ready
(
function
()
{
let
targetedId
;
$
(
'
#new
'
).
click
(
function
(
e
)
{
e
.
preventDefault
();
targetedId
=
undefined
;
$
(
'
input
'
).
val
(
''
);
});
$
.
ajax
({
url
:
"
http://0.0.0.0:81/web/app_dev.php/API/v2/brasserie
"
,
dataType
:
'
JSON
'
,
...
...
@@ -54,40 +60,23 @@ $(document).ready(function()
$
(
'
#send
'
).
click
(
function
(
e
)
{
e
.
preventDefault
();
if
(
typeof
targetedId
===
'
undefined
'
)
{
$
.
ajax
({
url
:
"
http://0.0.0.0:81/web/app_dev.php/API/v2/brasserie
"
,
dataType
:
'
JSON
'
,
method
:
'
POST
'
,
data
:
$
(
'
#form
'
).
serialize
(),
success
:
function
(
data
)
{
alert
(
'
success
'
);
},
error
:
function
(
xhr
)
{
console
.
log
(
xhr
);
alert
(
'
error
'
);
}
});
}
else
{
$
.
ajax
({
url
:
"
http://0.0.0.0:81/web/app_dev.php/API/v2/brasserie/
"
+
targetedId
,
dataType
:
'
JSON
'
,
method
:
'
PUT
'
,
data
:
$
(
'
#form
'
).
serialize
(),
success
:
function
(
data
)
{
alert
(
'
success
'
);
},
error
:
function
(
xhr
)
{
console
.
log
(
xhr
);
alert
(
'
error
'
);
}
$
.
ajax
({
url
:
"
http://0.0.0.0:81/web/app_dev.php/API/v2/brasserie
"
+
(
targetedId
!==
undefined
?
'
/
'
+
targetedId
:
''
),
dataType
:
'
JSON
'
,
method
:
(
targetedId
!==
undefined
?
'
PUT
'
:
'
POST
'
),
data
:
$
(
'
#form
'
).
serialize
(),
success
:
function
(
data
)
{
alert
(
'
success
'
);
},
error
:
function
(
xhr
)
{
console
.
log
(
xhr
);
alert
(
'
error
'
);
}
});
}
});
});
});
</script>
</html>
</body>
</html>
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