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 apk可以在模拟器上正常安装使用,但是手机上无法正常安装
  • ¥15 office打开卡退(新电脑重装office系统后)
  • ¥300 FLUENT 火箭发动机燃烧EDC仿真
  • ¥15 【Hadoop 问题】Hadoop编译所遇问题hadoop-common: make failed with error code 2
  • ¥15 vb6.0+webbrowser无法加载某个网页求解
  • ¥15 RPA财务机器人采购付款流程
  • ¥15 计算机图形多边形及三次样条曲线绘制
  • ¥15 根据protues画的图用keil写程序
  • ¥200 如何使用postGis实现最短领规划?
  • ¥15 pyinstaller打包错误