1
0
mirror of https://github.com/maximebf/php-debugbar.git synced 2025-07-25 18:51:42 +02:00

Use fetch instead of jQuery ajax (#630)

This commit is contained in:
Barry vd. Heuvel
2024-03-20 13:35:41 +01:00
committed by GitHub
parent 42beef04ff
commit 29c8b9c942
4 changed files with 20 additions and 14 deletions

View File

@@ -58,7 +58,7 @@ if (typeof(PhpDebugBar) == 'undefined') {
self.hide(); self.hide();
}); });
}); });
this.addSearch(); this.addSearch();
this.$overlay = $('<div />').addClass(csscls('overlay')).hide().appendTo('body'); this.$overlay = $('<div />').addClass(csscls('overlay')).hide().appendTo('body');
@@ -72,7 +72,7 @@ if (typeof(PhpDebugBar) == 'undefined') {
this.$loadmorebtn.show(); this.$loadmorebtn.show();
this.find({}, 0, this.handleFind.bind(this)); this.find({}, 0, this.handleFind.bind(this));
}, },
addSearch: function(){ addSearch: function(){
var self = this; var self = this;
var searchBtn = $('<button />') var searchBtn = $('<button />')
@@ -113,7 +113,7 @@ if (typeof(PhpDebugBar) == 'undefined') {
}); });
e.preventDefault(); e.preventDefault();
}); });
var method = $('<a />') var method = $('<a />')
.text(meta['method']) .text(meta['method'])
.on('click', function(e) { .on('click', function(e) {
@@ -147,7 +147,7 @@ if (typeof(PhpDebugBar) == 'undefined') {
self.find({uri: meta['uri']}, 0, self.handleFind.bind(self)); self.find({uri: meta['uri']}, 0, self.handleFind.bind(self));
e.preventDefault(); e.preventDefault();
}); });
$('<tr />') $('<tr />')
.append('<td>' + meta['datetime'] + '</td>') .append('<td>' + meta['datetime'] + '</td>')
.append('<td>' + meta['method'] + '</td>') .append('<td>' + meta['method'] + '</td>')
@@ -188,13 +188,19 @@ if (typeof(PhpDebugBar) == 'undefined') {
}, },
ajax: function(data, callback) { ajax: function(data, callback) {
$.ajax({ var url = this.get('url');
dataType: 'json', if (data) {
url: this.get('url'), url = url + '?' + new URLSearchParams(data);
data: data, }
success: callback,
ignoreDebugBarAjaxHandler: true fetch(url, {
}); method: "GET",
headers: {
"Accept": "application/json",
},
})
.then((data) => data.json())
.then(callback);
} }
}); });

View File

@@ -595,7 +595,7 @@ if (typeof(PhpDebugBar) == 'undefined') {
if (e.xdebug_link) { if (e.xdebug_link) {
if (e.xdebug_link.ajax) { if (e.xdebug_link.ajax) {
$('<a title="' + e.xdebug_link.url + '"></a>').on('click', function () { $('<a title="' + e.xdebug_link.url + '"></a>').on('click', function () {
$.ajax(e.xdebug_link.url); fetch(e.xdebug_link.url);
}).addClass(csscls('editor-link')).appendTo(header); }).addClass(csscls('editor-link')).appendTo(header);
} else { } else {
$('<a href="' + e.xdebug_link.url + '"></a>').addClass(csscls('editor-link')).appendTo(header); $('<a href="' + e.xdebug_link.url + '"></a>').addClass(csscls('editor-link')).appendTo(header);

View File

@@ -130,7 +130,7 @@
var header = $('<span title="Filename" />').addClass(csscls('filename')).text(stmt.xdebug_link.filename + ( stmt.xdebug_link.line ? "#" + stmt.xdebug_link.line : '')); var header = $('<span title="Filename" />').addClass(csscls('filename')).text(stmt.xdebug_link.filename + ( stmt.xdebug_link.line ? "#" + stmt.xdebug_link.line : ''));
if (stmt.xdebug_link.ajax) { if (stmt.xdebug_link.ajax) {
$('<a title="' + stmt.xdebug_link.url + '"></a>').on('click', function () { $('<a title="' + stmt.xdebug_link.url + '"></a>').on('click', function () {
$.ajax(stmt.xdebug_link.url); fetch(stmt.xdebug_link.url);
}).addClass(csscls('editor-link')).appendTo(header); }).addClass(csscls('editor-link')).appendTo(header);
} else { } else {
$('<a href="' + stmt.xdebug_link.url + '"></a>').addClass(csscls('editor-link')).appendTo(header); $('<a href="' + stmt.xdebug_link.url + '"></a>').addClass(csscls('editor-link')).appendTo(header);

View File

@@ -23,7 +23,7 @@
if (tpl.xdebug_link) { if (tpl.xdebug_link) {
if (tpl.xdebug_link.ajax) { if (tpl.xdebug_link.ajax) {
$('<a title="' + tpl.xdebug_link.url + '"></a>').on('click', function () { $('<a title="' + tpl.xdebug_link.url + '"></a>').on('click', function () {
$.ajax(tpl.xdebug_link.url); fetch(tpl.xdebug_link.url);
}).addClass(csscls('editor-link')).appendTo(header); }).addClass(csscls('editor-link')).appendTo(header);
} else { } else {
$('<a href="' + tpl.xdebug_link.url + '"></a>').addClass(csscls('editor-link')).appendTo(header); $('<a href="' + tpl.xdebug_link.url + '"></a>').addClass(csscls('editor-link')).appendTo(header);