Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/ajax/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript SyntaxError:意外标记<;(…)-dojo/ajax_Javascript_Ajax_Dojo - Fatal编程技术网

Javascript SyntaxError:意外标记<;(…)-dojo/ajax

Javascript SyntaxError:意外标记<;(…)-dojo/ajax,javascript,ajax,dojo,Javascript,Ajax,Dojo,我在我的项目中使用以下AJAX var _getWeatherInfo = function(ntown){ //Debugging console.log("Before dojo.xhrget"); //dojo ajax request used to call the PHP file and retrieve the towns data dojo.xhrGet({ handleAs: "json",

我在我的项目中使用以下AJAX

    var _getWeatherInfo = function(ntown){
    //Debugging
    console.log("Before dojo.xhrget");
      //dojo ajax request used to call the PHP file and retrieve the towns data
      dojo.xhrGet({
          handleAs: "json",
          timeout: 5000,
          //php file URL (location)
          url: "PHP/weather.php?ntown=" + ntown,

          load: function(results) {
              //send the results to the function _refreshWeatherList
              _refreshWeatherList(results);               
        }

    });
    //Debugging
    console.log("After dojo.xhrget");
}
以检索城市/城镇的天气数据。然而,我已经有一段时间没有参与这个项目了,我很难理解为什么它不再有效(上次我运行这个项目时它还在有效)

在浏览器控制台中,我收到以下错误:

SyntaxError: Unexpected token <
    at Object.b.fromJson (http://ajax.googleapis.com/ajax/libs/dojo/1.10.4/dojo/dojo.js:227:426)
    at Object.b._contentHandlers.b.contentHandlers.json (http://ajax.googleapis.com/ajax/libs/dojo/1.10.4/dojo/dojo.js:185:216)
    at t (http://ajax.googleapis.com/ajax/libs/dojo/1.10.4/dojo/dojo.js:189:392)
    at c (http://ajax.googleapis.com/ajax/libs/dojo/1.10.4/dojo/dojo.js:75:221)
    at d (http://ajax.googleapis.com/ajax/libs/dojo/1.10.4/dojo/dojo.js:75:10)
    at resolve.callback (http://ajax.googleapis.com/ajax/libs/dojo/1.10.4/dojo/dojo.js:76:350)
    at http://ajax.googleapis.com/ajax/libs/dojo/1.10.4/dojo/dojo.js:192:378
    at k (http://ajax.googleapis.com/ajax/libs/dojo/1.10.4/dojo/dojo.js:196:406)
    at n (http://ajax.googleapis.com/ajax/libs/dojo/1.10.4/dojo/dojo.js:196:332)
    at resolve (http://ajax.googleapis.com/ajax/libs/dojo/1.10.4/dojo/dojo.js:198:406)y @ dojo.js.uncompressed.js:14021(anonymous function) @ dojo.js.uncompressed.js:13981c @ dojo.js.uncompressed.js:4579d @ dojo.js.uncompressed.js:4560reject.errback @ dojo.js.uncompressed.js:4655c @ dojo.js.uncompressed.js:4594d @ dojo.js.uncompressed.js:4560reject.errback @ dojo.js.uncompressed.js:4655c @ dojo.js.uncompressed.js:4590d @ dojo.js.uncompressed.js:4560resolve.callback @ dojo.js.uncompressed.js:4640(anonymous function) @ dojo.js.uncompressed.js:14208k @ dojo.js.uncompressed.js:14488n @ dojo.js.uncompressed.js:14479resolve @ dojo.js.uncompressed.js:14643a @ dojo.js.uncompressed.js:14532k @ dojo.js.uncompressed.js:14503n @ dojo.js.uncompressed.js:14479resolve @ dojo.js.uncompressed.js:14643a @ dojo.js.uncompressed.js:14532k @ dojo.js.uncompressed.js:14509n @ dojo.js.uncompressed.js:14479resolve @ dojo.js.uncompressed.js:14643a @ dojo.js.uncompressed.js:14532k @ dojo.js.uncompressed.js:14503n @ dojo.js.uncompressed.js:14479resolve @ dojo.js.uncompressed.js:14643r @ dojo.js.uncompressed.js:11883f @ dojo.js.uncompressed.js:11909
SyntaxError:意外标记<
在Object.b.fromJson(http://ajax.googleapis.com/ajax/libs/dojo/1.10.4/dojo/dojo.js:227:426)
位于Object.b.\u contentHandlers.b.contentHandlers.json(http://ajax.googleapis.com/ajax/libs/dojo/1.10.4/dojo/dojo.js:185:216)
at t(http://ajax.googleapis.com/ajax/libs/dojo/1.10.4/dojo/dojo.js:189:392)
在c(http://ajax.googleapis.com/ajax/libs/dojo/1.10.4/dojo/dojo.js:75:221)
在d(http://ajax.googleapis.com/ajax/libs/dojo/1.10.4/dojo/dojo.js:75:10)
在resolve.callback(http://ajax.googleapis.com/ajax/libs/dojo/1.10.4/dojo/dojo.js:76:350)
在http://ajax.googleapis.com/ajax/libs/dojo/1.10.4/dojo/dojo.js:192:378
在k(http://ajax.googleapis.com/ajax/libs/dojo/1.10.4/dojo/dojo.js:196:406)
在n(http://ajax.googleapis.com/ajax/libs/dojo/1.10.4/dojo/dojo.js:196:332)
决心(http://ajax.googleapis.com/ajax/libs/dojo/1.10.4/dojo/dojo.js:198:406)y@dojo.js.uncompressed.js:14021(匿名函数)@dojo.js.uncompressed.js:13981c@dojo.js.uncompressed.js:4579d@dojo.js.uncompressed.js:4560reject.errback@dojo.js.uncompressed.js:4655c@dojo.js.uncompressed.js:4594d@dojo.js.uncompressed.js:4560reject.errback@dojo.js.uncompressed.js:4555c@dojo.js.uncompressed.jsdojo.js.uncompressed.js:4640(匿名函数)@dojo.js.uncompressed.js:14208k@dojo.js.uncompressed.js:14488n@dojo.js.uncompressed.js:14479resolve@dojo.js.uncompressed.js:14643a@dojo.js.uncompressed.js:14532k@dojo.js.uncompressed.js:14503n@dojo.js.uncompressed.js:14479resolve@dojo.js.uncompressed.js:14643a@dojo.js.uncompressed.js:14532k@dojo.js.uncompressed.js:14509ndojo.js.uncompressed.js:14479resolve@dojo.js.uncompressed.js:14643a@dojo.js.uncompressed.js:14532k@dojo.js.uncompressed.js:14503n@dojo.js.uncompressed.js:14479resolve@dojo.js.uncompressed.js:14643r@dojo.js.uncompressed.js:11883f@dojo.js.uncompressed.js:11909
我使用以下方法包括dojo:

<script src="//ajax.googleapis.com/ajax/libs/dojo/1.10.4/dojo/dojo.js"></script>

xhr响应:

"<!--Include Database connections info-->


↵↵(!)已弃用:mysql_connect():mysql扩展已弃用,将来将被删除:请在第6行的E:\Program Files(x86)\wamp\www\Weather Widget App master\PHP\configHome.PHP中使用mysqli或PDO↵调用堆栈↵#时间记忆功能定位↵10.0004244528{main}()..\weather.php:0↵20.0006248360include('E:\ProgramFiles(x86)\wamp\www\Weather Widget App master\PHP\configHome.PHP')..\Weather.PHP:2↵30.0006248936http://www.php.net/function.mysql-connect'target='''u new'>mysql\u connect↵()..\configHome.php:6↵↵
↵↵(!)警告:mysql\u select\u db()希望参数1是字符串,资源在第9行的E:\Program Files(x86)\wamp\www\Weather Widget App master\PHP\configHome.PHP中给出↵调用堆栈↵#时间记忆功能定位↵10.0004244528{main}()..\weather.php:0↵20.0006248360include('E:\ProgramFiles(x86)\wamp\www\Weather Widget App master\PHP\configHome.PHP')..\Weather.PHP:2↵30.0300257280http://www.php.net/function.mysql-select-db'target='''\u new'>mysql\u select\u db↵()..\configHome.php:9↵↵在mysql服务器上选择指定的数据库时出错:“

我的问题无效/已折旧的mysql。我用MYSQLi重写了我的MYSQL,一切都安排妥当了。

我在从一个服务返回JSON时遇到了这个问题,我以前在该服务中var_转储了一些东西。不明飞行物。希望它能帮助一些人,因为我浪费了10分钟来找出原因。

xhr请求是否收到响应?你能把它寄出去吗?我想知道你的服务器是否返回了格式错误的json。听起来服务器响应的是XML而不是JSONSorry,因为回复太晚了。我做了一些进一步的工作,在xhr响应中发现了一些有用的信息(感谢Russell的建议!)。更新:从xhr响应中,我的SQL连接/语句显然有一些错误。现在都修好了。谢谢你的帮助。