weixin_33713503 2015-09-17 18:29 采纳率: 0%
浏览 42

javascript / ajax / json中的错误

im gettin an error with this code. the error is : "Uncaught SyntaxError: Unexpected end of input" THIS IS MY FUNCTION

function buscarMaterias()
{
  var primeraVez = true;
  var desarolloMaterias;
  var infraMaterias;
  var value = sel.value;
  var ajax = new XMLHttpRequest();
  console.log(1+1);
    if(primeraVez)
  {
    console.log(1+2);
    ajax.open('GET', 'desarrollo.json');
    ajax.send();
    desarolloMaterias = JSON.parse(ajax.responseText);
    ajax.open('GET', 'infraestructura.json');
    ajax.send(); 
    infraMaterias = JSON.parse(ajax.responseText);
    primeraVez = false;
  }
  console.log(1+3);
  switch(value)
  {
  case "1":
    dibujarMaterias(desarolloMaterias);
    break;
  case "2":
    dibujarMaterias(infraMaterias); 
    break;
    default:
    dibujarMaterias([{"id":0,"descripcion":"ELIGE UNA CARRERA"}]);
  }

}

i know the error is from a missing {,;] etc, but i just cant get where is a missing character

  • 写回答

1条回答 默认 最新

  • weixin_33709219 2015-09-17 18:34
    关注

    You may have more errors, but this is one's for sure:

    In this line:

    var value = sel.value;
    

    because sel is not defined.

    I used the javascript console and got that error:

    Uncaught ReferenceError: sel is not defined(…)
    

    Use the javascript console for the browser you are using. I'm using Chrome's, but FF and IE have the same thing.

    评论

报告相同问题?

悬赏问题

  • ¥15 metadata提取的PDF元数据,如何转换为一个Excel
  • ¥15 关于arduino编程toCharArray()函数的使用
  • ¥100 vc++混合CEF采用CLR方式编译报错
  • ¥15 coze 的插件输入飞书多维表格 app_token 后一直显示错误,如何解决?
  • ¥15 vite+vue3+plyr播放本地public文件夹下视频无法加载
  • ¥15 c#逐行读取txt文本,但是每一行里面数据之间空格数量不同
  • ¥50 如何openEuler 22.03上安装配置drbd
  • ¥20 ING91680C BLE5.3 芯片怎么实现串口收发数据
  • ¥15 无线连接树莓派,无法执行update,如何解决?(相关搜索:软件下载)
  • ¥15 Windows11, backspace, enter, space键失灵