Project

General

Profile

Actions

Bug #98153

closed

add parameter in ajax with javascript

Added by razieh zivaralam over 2 years ago. Updated about 2 years ago.

Status:
Closed
Priority:
Should have
Assignee:
-
Category:
-
Target version:
-
Start date:
2022-08-16
Due date:
% Done:

0%

Estimated time:
TYPO3 Version:
11
PHP Version:
Tags:
Complexity:
Is Regression:
Sprint Focus:

Description

hello I used the bookmark extension which uses ajax but with jquery

ajax (url, data = {}) {
data = {...data, 'tx_bookmarkpages_bookmarks[localBookmarks]': storage.list}
$.ajax({
url: url,
type: 'post',
data: data
}).done($.proxy(this.listQueryHandler, this));
},

this is a code that is used in bookmark extension
I try to translate this code to javascript

with fetch
async ajax (url, data = {}) {
data = {...data, 'tx_bookmarkpages_bookmarks[localBookmarks]: storage.list}
var $this=this;
let response = await fetch(url, {
method: 'POST',
headers: {
'Content-Type': 'application/json;charset=utf-8'
},
body: data
});
let result = await response.json();
$this.listQueryHandler(result);
},

or just with XMLHttpRequest

ajax (url, data = {}) {
data = {...data, 'tx_bookmarkpages_bookmarks[localBookmarks]': storage.list};
var xhttp = new XMLHttpRequest(),
$this=this;
xhttp.open("POST", url, true);
xhttp.onreadystatechange = function() {
if (this.readyState 4 && this.status 200) {
$this.listQueryHandler(JSON.parse( this.responseText));
}
};
xhttp.send(JSON.stringify(data));
},

I think these codes don't send data as a parameter like in jquery

and when I log in with a user I can add pages as a bookmark but I can't remove it ..... when I don't log in with any user it works well just for one page
how can fix this bug?

Actions #1

Updated by Chris Müller over 2 years ago

This is not a bug in TYPO3 Core. You may find support for your rewrite from jQuery to vanilla JavaScript in a specific extension on Slack (for example the "random" channel https://app.slack.com/client/T024TUMLZ/C024TUMM7) or on StackOverflow.

Actions #2

Updated by Georg Ringer about 2 years ago

  • Status changed from New to Closed

closing issue because not a problem of core

Actions

Also available in: Atom PDF