Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

196
Visualizações
CORB from Vanilla JS getJSONP to Google Apps Script

I have a simple set up in which I populate data on my HTML page by accessing data in a Google Sheet.

This works perfectly well in Chrome, but in Edge I get a CORB error in the console. I'm using Google Apps Script and Vanilla JS. My Google Apps Script is

function doGet(request) {
  var res = getData();
  return ContentService.createTextOutput(
    request.parameters.prefix + '(' + JSON.stringify(res) + ')')
    .setMimeType(ContentService.MimeType.JAVASCRIPT);
}
 
//GET DATA FROM GOOGLE SHEET AND RETURN AS AN ARRAY
function getData(){
  var spreadSheetId = "mySpreadsheetID";
  var dataRange     = "Projects!A2:J50";
 
  var range   = GoogleSheetsAPI.Spreadsheets.Values.get(spreadSheetId,dataRange);
  return range.values;
}

and my JavaScript is:

var gScriptURL = "https://script.google.com/a/macros/blah/s/blahblahblah/exec?prefix=console.log&dataType=json&callback=?";

var loadJSONP = (function(){
  var unique = 0;
  return function(url, callback, context) {

    var script = document.createElement("script");
    script.type = "text/javascript";
    script.src = url;

    window[name] = function(data){
      callback.call((context || window), data);
      document.getElementsByTagName("head")[0].removeChild(script);
      script = null;
      delete window[name];
    };

    document.getElementsByTagName("head")[0].appendChild(script);
  };
})();

function getData(){
    loadJSONP(
    gScriptURL,
    function(data) {
      console.log(data);
    }
  );
}

In Google Chrome, I get an array dumped to the console, in Edge I get:

Cross-Origin Read Blocking (CORB) blocked cross-origin response https://url.com/login/login.htm?fromURI=blahblah with MIME type text/html. See https://www.chromestatus.com/feature/5629709824032768 for more details.

Which seems to have issues with MIME type text/html, but I'm explicitly requesting json. Or am I!?

about 4 years ago · Juan Pablo Isaza
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda