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 存储过程或函数中的结果集类型变量如何使用。
    • ¥80 关于海信电视聚好看安装应用的问题
    • ¥15 vue引入sdk后的回调问题
    • ¥15 求一个智能家居控制的代码
    • ¥15 ad软件 pcb布线pcb规则约束编辑器where the object matpcb布线pcb规则约束编辑器where the object matchs怎么没有+15v只有no net
    • ¥15 虚拟机vmnet8 nat模式可以ping通主机,主机也能ping通虚拟机,但是vmnet8一直未识别怎么解决,其次诊断结果就是默认网关不可用
    • ¥20 求各位能用我能理解的话回答超级简单的一些问题
    • ¥15 yolov5双目识别输出坐标代码报错
    • ¥15 这个代码有什么语法错误
    • ¥15 给予STM32按键中断与串口通信