回答編集履歴
2
情報の追加。
test
CHANGED
@@ -24,7 +24,7 @@
|
|
24
24
|
|
25
25
|
|
26
26
|
|
27
|
-
**追記:**
|
27
|
+
**追記:**(2017/06/01編集)
|
28
28
|
|
29
29
|
|
30
30
|
|
@@ -34,9 +34,17 @@
|
|
34
34
|
|
35
35
|
var jqxhr;
|
36
36
|
|
37
|
+
var count = 0;
|
38
|
+
|
37
39
|
$("#input").autocomplete({
|
38
40
|
|
39
41
|
source: function(req, resp){
|
42
|
+
|
43
|
+
count++;
|
44
|
+
|
45
|
+
var ct = count;
|
46
|
+
|
47
|
+
console.log( 'set:' + ct + ' / req:' + req.term );
|
40
48
|
|
41
49
|
if(jqxhr){
|
42
50
|
|
@@ -68,6 +76,8 @@
|
|
68
76
|
|
69
77
|
success: function(o){
|
70
78
|
|
79
|
+
console.log( 'success:' + ct + ' / req:' + req.term);
|
80
|
+
|
71
81
|
resp($.map(o, function(item) {
|
72
82
|
|
73
83
|
return {
|
@@ -83,6 +93,8 @@
|
|
83
93
|
},
|
84
94
|
|
85
95
|
error: function(xhr, ts, err){
|
96
|
+
|
97
|
+
console.log( 'error:' + ct + ' / req:' + req.term);
|
86
98
|
|
87
99
|
//エラー時の処理
|
88
100
|
|
1
情報の追加。
test
CHANGED
@@ -17,3 +17,91 @@
|
|
17
17
|
} // 未テスト
|
18
18
|
|
19
19
|
```
|
20
|
+
|
21
|
+
|
22
|
+
|
23
|
+
---
|
24
|
+
|
25
|
+
|
26
|
+
|
27
|
+
**追記:**
|
28
|
+
|
29
|
+
|
30
|
+
|
31
|
+
```JavaScript
|
32
|
+
|
33
|
+
$(function(){
|
34
|
+
|
35
|
+
var jqxhr;
|
36
|
+
|
37
|
+
$("#input").autocomplete({
|
38
|
+
|
39
|
+
source: function(req, resp){
|
40
|
+
|
41
|
+
if(jqxhr){
|
42
|
+
|
43
|
+
jqxhr.abort();
|
44
|
+
|
45
|
+
}
|
46
|
+
|
47
|
+
if(req.term==""){
|
48
|
+
|
49
|
+
return false;
|
50
|
+
|
51
|
+
}
|
52
|
+
|
53
|
+
jqxhr = $.ajax({
|
54
|
+
|
55
|
+
url: "autocomplete.php",
|
56
|
+
|
57
|
+
type: "POST",
|
58
|
+
|
59
|
+
cache: false,
|
60
|
+
|
61
|
+
dataType: "json",
|
62
|
+
|
63
|
+
data: {
|
64
|
+
|
65
|
+
name: req.term
|
66
|
+
|
67
|
+
},
|
68
|
+
|
69
|
+
success: function(o){
|
70
|
+
|
71
|
+
resp($.map(o, function(item) {
|
72
|
+
|
73
|
+
return {
|
74
|
+
|
75
|
+
label: item.name,
|
76
|
+
|
77
|
+
value: item.name
|
78
|
+
|
79
|
+
}
|
80
|
+
|
81
|
+
}));
|
82
|
+
|
83
|
+
},
|
84
|
+
|
85
|
+
error: function(xhr, ts, err){
|
86
|
+
|
87
|
+
//エラー時の処理
|
88
|
+
|
89
|
+
console.log("error");
|
90
|
+
|
91
|
+
}
|
92
|
+
|
93
|
+
});
|
94
|
+
|
95
|
+
},
|
96
|
+
|
97
|
+
select: function(event, ui){
|
98
|
+
|
99
|
+
//候補から選んだ時の処理
|
100
|
+
|
101
|
+
}
|
102
|
+
|
103
|
+
});
|
104
|
+
|
105
|
+
}); // 未テスト
|
106
|
+
|
107
|
+
```
|