dropdownlist met jquery en ajax
Code (php)
1
2
3
4
5
2
3
4
5
$(document).ready(function () {
$("#dropdownlist").change(function () {
alert("Doet het!");
});
});
$("#dropdownlist").change(function () {
alert("Doet het!");
});
});
Alleen nu moet die via ajax een request gestuurd worden naar het ashx bestand met het geselecteerde item. weet iemand hoe je dit doet?
ik heb al iets als dit:
Code (php)
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
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
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>Dropdownlist</title>
<script src="beheer/Scripts/jquery-1.7.1.min.js"></script>
<script>
$(document).ready(function () {
$("#dropdownlist").change(function () {
alert($("#dropdownlist").val(showUser));
var data = new FormData();
data.append("name", $("#dropdownlist").val());
var options = {};
options.url = "dropdownlist.ashx";
options.type = "POST";
options.data = data;
options.contentType = false;
options.processData = false;
options.success = function (result) {
alert(result);
};
options.error = function (err) { alert(err.statusText); };
$.ajax(options);
});
});
</script>
</head>
<body>
<form id="form1" runat="server">
<div>
<select name="test" id="dropdownlist" change="showUser(this.value)">
<option value="">~~~</option>
<option value="BMW">BMW</option>
<option value="Audi">Audi</option>
</select>
</div>
</form>
</body>
</html>
<head runat="server">
<title>Dropdownlist</title>
<script src="beheer/Scripts/jquery-1.7.1.min.js"></script>
<script>
$(document).ready(function () {
$("#dropdownlist").change(function () {
alert($("#dropdownlist").val(showUser));
var data = new FormData();
data.append("name", $("#dropdownlist").val());
var options = {};
options.url = "dropdownlist.ashx";
options.type = "POST";
options.data = data;
options.contentType = false;
options.processData = false;
options.success = function (result) {
alert(result);
};
options.error = function (err) { alert(err.statusText); };
$.ajax(options);
});
});
</script>
</head>
<body>
<form id="form1" runat="server">
<div>
<select name="test" id="dropdownlist" change="showUser(this.value)">
<option value="">~~~</option>
<option value="BMW">BMW</option>
<option value="Audi">Audi</option>
</select>
</div>
</form>
</body>
</html>
Klopt natuurlijk niks van.
Er zijn nog geen reacties op dit bericht.