Use axios for all ajax requests
This commit is contained in:
@@ -8,6 +8,7 @@
|
|||||||
</template>
|
</template>
|
||||||
<script>
|
<script>
|
||||||
import $ from 'jquery'
|
import $ from 'jquery'
|
||||||
|
import axios from 'axios'
|
||||||
import EventBus from '../_bus'
|
import EventBus from '../_bus'
|
||||||
const $window = $(window);
|
const $window = $(window);
|
||||||
|
|
||||||
@@ -22,11 +23,16 @@
|
|||||||
props: [ 'uri', 'loaderUri' ],
|
props: [ 'uri', 'loaderUri' ],
|
||||||
methods: {
|
methods: {
|
||||||
loadContent () {
|
loadContent () {
|
||||||
$.get(this.uri, (html) => {
|
axios({
|
||||||
|
url: this.uri,
|
||||||
|
responseType: 'text'
|
||||||
|
}).then((response) => {
|
||||||
this.loading = false;
|
this.loading = false;
|
||||||
this.html = html;
|
this.html = response.data;
|
||||||
$(this.$refs.trigger).remove();
|
$(this.$refs.trigger).remove();
|
||||||
EventBus.$emit('ajaxContentLoaded');
|
EventBus.$emit('ajaxContentLoaded');
|
||||||
|
}).catch(() => {
|
||||||
|
this.loading = false;
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
isInViewport ($triggerElement) {
|
isInViewport ($triggerElement) {
|
||||||
|
|||||||
@@ -25,7 +25,7 @@
|
|||||||
</template>
|
</template>
|
||||||
<script>
|
<script>
|
||||||
import Vue from 'vue'
|
import Vue from 'vue'
|
||||||
import $ from 'jquery'
|
import axios from 'axios'
|
||||||
import dayjs from 'dayjs'
|
import dayjs from 'dayjs'
|
||||||
import 'dayjs/locale/de'
|
import 'dayjs/locale/de'
|
||||||
|
|
||||||
@@ -85,8 +85,14 @@
|
|||||||
query[this.argumentPrefix + '[months]'] = this.months;
|
query[this.argumentPrefix + '[months]'] = this.months;
|
||||||
this.loading = true;
|
this.loading = true;
|
||||||
this.showPrev = this.startDate.isAfter(dayjs());
|
this.showPrev = this.startDate.isAfter(dayjs());
|
||||||
$.get(this.uri, query, (html) => {
|
axios({
|
||||||
this.calendarHtml = html;
|
url: this.uri,
|
||||||
|
responseType: 'text',
|
||||||
|
params: query
|
||||||
|
}).then((response) => {
|
||||||
|
this.calendarHtml = response.data;
|
||||||
|
this.loading = false;
|
||||||
|
}).catch(() => {
|
||||||
this.loading = false;
|
this.loading = false;
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|||||||
+10
-3
@@ -26,6 +26,7 @@
|
|||||||
|
|
||||||
<script>
|
<script>
|
||||||
import $ from 'jquery'
|
import $ from 'jquery'
|
||||||
|
import axios from 'axios'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
props: {
|
props: {
|
||||||
@@ -74,14 +75,20 @@
|
|||||||
let query = {};
|
let query = {};
|
||||||
query[this.argumentPrefix + '[filterSettings]'] = this.filterSettings;
|
query[this.argumentPrefix + '[filterSettings]'] = this.filterSettings;
|
||||||
query[this.argumentPrefix + '[search]'] = this.destination;
|
query[this.argumentPrefix + '[search]'] = this.destination;
|
||||||
$.post(this.ajaxUri, query, (json) => {
|
axios({
|
||||||
this.autocompleteOptions = json;
|
url: this.ajaxUri,
|
||||||
|
method: 'post',
|
||||||
|
data: $.param(query)
|
||||||
|
}).then((response) => {
|
||||||
|
this.autocompleteOptions = response.data;
|
||||||
this.showAutocompleteOptions = this.hasOptions();
|
this.showAutocompleteOptions = this.hasOptions();
|
||||||
if (this.showAutocompleteOptions) {
|
if (this.showAutocompleteOptions) {
|
||||||
this.openDropdown();
|
this.openDropdown();
|
||||||
}
|
}
|
||||||
this.loading = false;
|
this.loading = false;
|
||||||
}, 'json');
|
}).catch(() => {
|
||||||
|
this.loading = false;
|
||||||
|
});
|
||||||
},
|
},
|
||||||
toggleOptions () {
|
toggleOptions () {
|
||||||
if (!this.hasOptions()) {
|
if (!this.hasOptions()) {
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
<script>
|
<script>
|
||||||
import $ from 'jquery'
|
import axios from 'axios'
|
||||||
import DaterangeSelect from './DaterangeSelect.vue'
|
import DaterangeSelect from './DaterangeSelect.vue'
|
||||||
import DestinationSelect from './DestinationSelect.vue'
|
import DestinationSelect from './DestinationSelect.vue'
|
||||||
import PaxSelect from './PaxSelect.vue'
|
import PaxSelect from './PaxSelect.vue'
|
||||||
@@ -25,9 +25,13 @@
|
|||||||
loadOptions () {
|
loadOptions () {
|
||||||
const query = {};
|
const query = {};
|
||||||
query[this.argumentPrefix + '[searchParams]'] = this.searchParams;
|
query[this.argumentPrefix + '[searchParams]'] = this.searchParams;
|
||||||
$.post(this.optionsUri, query, (json) => {
|
axios({
|
||||||
this.applyOptions(json);
|
url: this.optionsUri,
|
||||||
}, 'json');
|
method: 'post',
|
||||||
|
data: $.param(query)
|
||||||
|
}).then((response) => {
|
||||||
|
this.applyOptions(response.data);
|
||||||
|
});
|
||||||
},
|
},
|
||||||
applyOptions (json) {
|
applyOptions (json) {
|
||||||
this.filterOptions.totalResults = json.totalResults;
|
this.filterOptions.totalResults = json.totalResults;
|
||||||
@@ -65,9 +69,12 @@
|
|||||||
this.loadOptions();
|
this.loadOptions();
|
||||||
},
|
},
|
||||||
resetDestination () {
|
resetDestination () {
|
||||||
$.post(this.resetUri, (json) => {
|
axios({
|
||||||
this.searchParams = json.searchParams;
|
url: this.resetUri,
|
||||||
this.applyOptions(json);
|
method: 'post'
|
||||||
|
}).then((response) => {
|
||||||
|
this.applyOptions(response.data);
|
||||||
|
this.searchParams = response.data.searchParams;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
<script>
|
<script>
|
||||||
import $ from 'jquery'
|
import $ from 'jquery'
|
||||||
|
import axios from 'axios'
|
||||||
import DestinationSelect from './DestinationSelect.vue'
|
import DestinationSelect from './DestinationSelect.vue'
|
||||||
import PriceRangeSelect from './PriceRangeSelect.vue'
|
import PriceRangeSelect from './PriceRangeSelect.vue'
|
||||||
|
|
||||||
@@ -19,9 +20,13 @@
|
|||||||
loadOptions () {
|
loadOptions () {
|
||||||
const query = {};
|
const query = {};
|
||||||
query[this.argumentPrefix + '[searchParams]'] = this.searchParams;
|
query[this.argumentPrefix + '[searchParams]'] = this.searchParams;
|
||||||
$.post(this.optionsUri, query, (json) => {
|
axios({
|
||||||
this.applyOptions(json);
|
url: this.optionsUri,
|
||||||
}, 'json');
|
method: 'post',
|
||||||
|
data: $.param(query)
|
||||||
|
}).then((response) => {
|
||||||
|
this.applyOptions(response.data);
|
||||||
|
});
|
||||||
},
|
},
|
||||||
applyOptions (json) {
|
applyOptions (json) {
|
||||||
this.filterOptions.totalResults = json.totalResults;
|
this.filterOptions.totalResults = json.totalResults;
|
||||||
@@ -52,9 +57,12 @@
|
|||||||
this.loadOptions();
|
this.loadOptions();
|
||||||
},
|
},
|
||||||
resetDestination () {
|
resetDestination () {
|
||||||
$.post(this.resetUri, (json) => {
|
axios({
|
||||||
this.searchParams = json.searchParams;
|
url: this.resetUri,
|
||||||
this.applyOptions(json);
|
method: 'post'
|
||||||
|
}).then((response) => {
|
||||||
|
this.applyOptions(response.data);
|
||||||
|
this.searchParams = response.data.searchParams;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
<script>
|
<script>
|
||||||
import Vue from 'vue';
|
import Vue from 'vue';
|
||||||
import $ from 'jquery'
|
import $ from 'jquery'
|
||||||
|
import axios from 'axios'
|
||||||
import EventBus from '../_bus'
|
import EventBus from '../_bus'
|
||||||
import DaterangeSelect from './DaterangeSelect.vue'
|
import DaterangeSelect from './DaterangeSelect.vue'
|
||||||
import DestinationCheckboxes from './DestinationCheckboxes.vue'
|
import DestinationCheckboxes from './DestinationCheckboxes.vue'
|
||||||
@@ -128,12 +129,18 @@
|
|||||||
query[this.argumentPrefix + '[filterSettings]'] = this.filterSettings;
|
query[this.argumentPrefix + '[filterSettings]'] = this.filterSettings;
|
||||||
this.loading = true;
|
this.loading = true;
|
||||||
this.resultMeta = null;
|
this.resultMeta = null;
|
||||||
$.post(this.resultsUri, query, (json) => {
|
axios({
|
||||||
this.resultData = json.data;
|
url: this.resultsUri,
|
||||||
this.filterOptions = json.filterOptions;
|
method: 'post',
|
||||||
this.resultMeta = json.meta;
|
data: $.param(query)
|
||||||
|
}).then((response) => {
|
||||||
|
this.resultData = response.data.data;
|
||||||
|
this.filterOptions = response.data.filterOptions;
|
||||||
|
this.resultMeta = response.data.meta;
|
||||||
this.loading = false;
|
this.loading = false;
|
||||||
EventBus.$emit('ajaxContentLoaded');
|
EventBus.$emit('ajaxContentLoaded');
|
||||||
|
}).catch(() => {
|
||||||
|
this.loading = false;
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
resetFilterSettings () {
|
resetFilterSettings () {
|
||||||
|
|||||||
@@ -23,6 +23,7 @@
|
|||||||
|
|
||||||
<script>
|
<script>
|
||||||
import Vue from 'vue'
|
import Vue from 'vue'
|
||||||
|
import axios from 'axios'
|
||||||
import EventBus from '../_bus'
|
import EventBus from '../_bus'
|
||||||
import SearchResultItem from './SearchResultItem.vue'
|
import SearchResultItem from './SearchResultItem.vue'
|
||||||
|
|
||||||
@@ -71,11 +72,19 @@
|
|||||||
let query = {};
|
let query = {};
|
||||||
query['tx_epproducts_ajax[watchlistUids]'] = this.watchlist;
|
query['tx_epproducts_ajax[watchlistUids]'] = this.watchlist;
|
||||||
this.loading = true;
|
this.loading = true;
|
||||||
$.post(this.watchlistUri, query, (json) => {
|
axios({
|
||||||
this.teasers = json.data;
|
url: this.watchlistUri,
|
||||||
this.total = json.total;
|
headers: {
|
||||||
|
'Accept': 'application/json'
|
||||||
|
},
|
||||||
|
params: query
|
||||||
|
}).then((response) => {
|
||||||
|
this.teasers = response.data.data;
|
||||||
|
this.total = response.data.total;
|
||||||
this.loading = false;
|
this.loading = false;
|
||||||
EventBus.$emit('ajaxContentLoaded');
|
EventBus.$emit('ajaxContentLoaded');
|
||||||
|
}).catch(() => {
|
||||||
|
this.loading = false;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user