-1

Im programing a Chrome Extension and wanted to make a Jquery Request from my background.js I read that its not possible, and only possible from the content.js or a popup.js, but when making my request it can be that the user closed the page, where the content.js was running (same for the popup), so how do I handle this?

PS: Im using V13

  • Why do you need jQuery? Write your code without jQuery. – jabaa Jun 23 '22 at 15:43
  • Im trying to do an AJAX Call to my server. Im sending user data, and there is not necessarily a tab opened, when I have the user data. – TheGuyFromThePlace Jun 23 '22 at 15:49
  • You don't need jQuery for AJAX calls. I don't know of any advantages using jQuery for this. – jabaa Jun 23 '22 at 15:51
  • What do I use instead? Till now I only used jQuery and only found samples using jQuery? – TheGuyFromThePlace Jun 23 '22 at 15:54
  • 1
    You should use the [Fetch API](https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API/Using_Fetch). There is no reason to use jQuery in 2022 except some plugins. Examples using jQuery are usually really outdated. – jabaa Jun 23 '22 at 15:56

1 Answers1

0

You can use the fetch() method:

https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API/Using_Fetch