How do I get a JSON file to pick variables in Javascript?

Asked

Viewed 59 times

0

It’s a Google extension where I copy a text from a page and I copy a JSON with what was copied, but I’m not sure how to do it correctly. I managed to do this part but I’m not sure if I have a JSON.

chrome.contextMenus.onClicked.addListener(function(Clique)){
    if(Clique.menuItemId == "Clipenews_paragrafo"){
       console.log("Sucesso");
       var texto = Clique.selectionText;
       $.ajax({
         url: 'localhost',
         dataType: 'json',
         method: 'post'
          data:{ data:JSON.stringify(texto)},
     });
    console.log(texto)
}
  • What kind of content can this have Clique.selectionText? See if this answer helps: How to convert formdata to json?.

  • Click.selectionText takes what was selected and copied by the mouse and plays in the var text

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.