|
47 | 47 | return; |
48 | 48 | } |
49 | 49 |
|
50 | | - xmlhttp.onreadystatechange = function () { |
51 | | - var jsonResponse; |
52 | | - |
53 | | - if (xmlhttp.readyState === 4) { |
54 | | - if (xmlhttp.status === 200) { |
55 | | - jsonResponse = JSON.parse(xmlhttp.response); |
56 | | - responseCallback(jsonResponse.recommendationItems, this); |
57 | | - } else if (xmlhttp.status === 401) { |
58 | | - errorCallback(this.unauthorizedMessage); |
59 | | - } else if (xmlhttp.status === 500) { |
60 | | - errorCallback(this.internalServerErrorMessage); |
61 | | - } else { |
62 | | - errorCallback(this.errorMessage); |
63 | | - } |
64 | | - } |
65 | | - }.bind(this); |
66 | | - |
67 | 50 | for (var i = 0; i < this.fields.length; i++) { |
68 | 51 | attributes = attributes + '&attribute=' + this.fields[i]; |
69 | 52 | } |
|
82 | 65 | ]; |
83 | 66 |
|
84 | 67 | xmlhttp.open('GET', requestQueryString.join(''), true); |
| 68 | + xmlhttp.onload = function (e) { |
| 69 | + var jsonResponse; |
| 70 | + |
| 71 | + if (xmlhttp.readyState === 4) { |
| 72 | + if (xmlhttp.status === 200) { |
| 73 | + jsonResponse = JSON.parse(xmlhttp.response); |
| 74 | + responseCallback(jsonResponse.recommendationItems, this); |
| 75 | + } else if (xmlhttp.status === 401) { |
| 76 | + errorCallback(this.unauthorizedMessage); |
| 77 | + } else if (xmlhttp.status === 500) { |
| 78 | + errorCallback(this.internalServerErrorMessage); |
| 79 | + } else { |
| 80 | + errorCallback(this.errorMessage); |
| 81 | + } |
| 82 | + } |
| 83 | + }.bind(this); |
| 84 | + |
| 85 | + |
85 | 86 | xmlhttp.send(); |
86 | 87 | }; |
87 | 88 |
|
|
99 | 100 | return true; |
100 | 101 | } |
101 | 102 |
|
102 | | - xmlhttp.open('GET', url, false); |
| 103 | + xmlhttp.open('GET', url, true); |
103 | 104 | xmlhttp.send(); |
104 | 105 |
|
105 | 106 | return true; |
|
0 commit comments