Skip to content

Commit 29c8b9c

Browse files
authored
Use fetch instead of jQuery ajax (php-debugbar#630)
1 parent 42beef0 commit 29c8b9c

File tree

4 files changed

+20
-14
lines changed

4 files changed

+20
-14
lines changed

src/DebugBar/Resources/openhandler.js

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ if (typeof(PhpDebugBar) == 'undefined') {
5858
self.hide();
5959
});
6060
});
61-
61+
6262
this.addSearch();
6363

6464
this.$overlay = $('<div />').addClass(csscls('overlay')).hide().appendTo('body');
@@ -72,7 +72,7 @@ if (typeof(PhpDebugBar) == 'undefined') {
7272
this.$loadmorebtn.show();
7373
this.find({}, 0, this.handleFind.bind(this));
7474
},
75-
75+
7676
addSearch: function(){
7777
var self = this;
7878
var searchBtn = $('<button />')
@@ -113,7 +113,7 @@ if (typeof(PhpDebugBar) == 'undefined') {
113113
});
114114
e.preventDefault();
115115
});
116-
116+
117117
var method = $('<a />')
118118
.text(meta['method'])
119119
.on('click', function(e) {
@@ -147,7 +147,7 @@ if (typeof(PhpDebugBar) == 'undefined') {
147147
self.find({uri: meta['uri']}, 0, self.handleFind.bind(self));
148148
e.preventDefault();
149149
});
150-
150+
151151
$('<tr />')
152152
.append('<td>' + meta['datetime'] + '</td>')
153153
.append('<td>' + meta['method'] + '</td>')
@@ -188,13 +188,19 @@ if (typeof(PhpDebugBar) == 'undefined') {
188188
},
189189

190190
ajax: function(data, callback) {
191-
$.ajax({
192-
dataType: 'json',
193-
url: this.get('url'),
194-
data: data,
195-
success: callback,
196-
ignoreDebugBarAjaxHandler: true
197-
});
191+
var url = this.get('url');
192+
if (data) {
193+
url = url + '?' + new URLSearchParams(data);
194+
}
195+
196+
fetch(url, {
197+
method: "GET",
198+
headers: {
199+
"Accept": "application/json",
200+
},
201+
})
202+
.then((data) => data.json())
203+
.then(callback);
198204
}
199205

200206
});

src/DebugBar/Resources/widgets.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -595,7 +595,7 @@ if (typeof(PhpDebugBar) == 'undefined') {
595595
if (e.xdebug_link) {
596596
if (e.xdebug_link.ajax) {
597597
$('<a title="' + e.xdebug_link.url + '"></a>').on('click', function () {
598-
$.ajax(e.xdebug_link.url);
598+
fetch(e.xdebug_link.url);
599599
}).addClass(csscls('editor-link')).appendTo(header);
600600
} else {
601601
$('<a href="' + e.xdebug_link.url + '"></a>').addClass(csscls('editor-link')).appendTo(header);

src/DebugBar/Resources/widgets/sqlqueries/widget.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@
130130
var header = $('<span title="Filename" />').addClass(csscls('filename')).text(stmt.xdebug_link.filename + ( stmt.xdebug_link.line ? "#" + stmt.xdebug_link.line : ''));
131131
if (stmt.xdebug_link.ajax) {
132132
$('<a title="' + stmt.xdebug_link.url + '"></a>').on('click', function () {
133-
$.ajax(stmt.xdebug_link.url);
133+
fetch(stmt.xdebug_link.url);
134134
}).addClass(csscls('editor-link')).appendTo(header);
135135
} else {
136136
$('<a href="' + stmt.xdebug_link.url + '"></a>').addClass(csscls('editor-link')).appendTo(header);

src/DebugBar/Resources/widgets/templates/widget.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
if (tpl.xdebug_link) {
2424
if (tpl.xdebug_link.ajax) {
2525
$('<a title="' + tpl.xdebug_link.url + '"></a>').on('click', function () {
26-
$.ajax(tpl.xdebug_link.url);
26+
fetch(tpl.xdebug_link.url);
2727
}).addClass(csscls('editor-link')).appendTo(header);
2828
} else {
2929
$('<a href="' + tpl.xdebug_link.url + '"></a>').addClass(csscls('editor-link')).appendTo(header);

0 commit comments

Comments
 (0)