Nextrek
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
|
<html>
<head>
<script type="text/javascript" src="https://code.jquery.com/jquery-2.1.4.min.js"></script>
</head>
<body>
<form id="submit">
ID Locale:<br>
<input type="text" name="local_id">
<br>
ID Utente Autore:<br>
<input type="text" name="user_id">
<br>
Voto:<br>
<select name="voto">
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="5">5</option>
</select>
<br>
Commento:<br>
<textarea name="descrizione"></textarea>
<br>
<input type="submit" value="Pubblica">
</form>
<form id="submit_image">
<input type="hidden" name="action" value="upload" />
<label>Carica immagine commento:</label>
<input type="file" name="image_file" />
<br />
<input type="submit" value="Carica immagine">
</form>
<br>
<div id="output_submit"></div>
<div id="output_submit_image"></div>
<script>
var imgs = new Array();
$(document).ready(function() {
$("#submit").submit(function(e) {
e.preventDefault();
var local_id = $("#submit input[name='local_id']").val();
var user_id = $("#submit input[name='user_id']").val();
var voto = $("#submit select[name='voto'] option:selected").val();
var descrizione = $("#submit textarea[name='descrizione']").val();
var params = {
local_id: local_id,
user_id: user_id,
voto: voto,
descrizione: descrizione,
data: new Date(),
imgs: imgs
}
params = JSON.stringify(params);
function ajaxResAddComment(data) {
var json_output = JSON.stringify(data);
$("#output_submit").append(json_output);
imgs = [];
}
$.ajax({
url: "../add_commento.php",
success: ajaxResAddComment,
method: "POST",
data: params
});
})
$("#submit_image").submit(function(e) {
e.preventDefault();
var formData = new FormData();
var image_file = $("#submit_image input[name='image_file']")[0].files[0]
formData.append("image_file", image_file);
function ajaxResUploadImage(data) {
//var json_output = JSON.stringify(data);
var jsonObj = JSON.parse(data);
imgs.push(jsonObj.image_file);
$("#output_submit_image").append(data);
}
$.ajax({
url: '../upload_image.php',
data: formData,
cache: false,
contentType: false,
processData: false,
type: 'POST',
success: ajaxResUploadImage
});
});
});
</script>
</body>
</html>
|
Revision |
Author |
Commited |
Message |
310
|
FSallustio
|
Tue 14 Jul, 2015 07:27:01 +0000 |
|