SyntaxError: Unexpected Token <(...) - dojo/ajax
SyntaxError: Unexpected Token <(...) - dojo/ajax
我在我的项目中使用了以下 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");
}
为了检索 cities/towns 的天气数据。然而,自从我从事这个项目以来已经有一段时间了,我无法理解为什么它不再起作用(上次我 运行 这个项目时它起作用了)。
在浏览器控制台中,我收到以下错误:
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
我包括 dojo 使用:
<script src="//ajax.googleapis.com/ajax/libs/dojo/1.10.4/dojo/dojo.js"></script>
xhr 响应:
"<!--Include Database connections info-->
↵
↵↵( ! ) 已弃用:mysql_connect():mysql 扩展已弃用,将来会被删除:使用 mysqli或 PDO 代替 E:\Program Files (x86)\wamp\www\Weather-Widget-App-master\PHP\configHome.php 行 6↵Call Stack↵#TimeMemoryFunctionLocation↵10.0004244528{main}( )。 .\weather.php:0↵20.0006248360include('E:\Program Files (x86)\wamp\www\Weather-Widget-App-master\PHP\configHome.php')..\weather.php:2↵ 30.0006248936http://www.php.net/function.mysql-connect' target='_new'>mysql_connect↵( )..\configHome.php:6↵↵
↵↵( ! ) 警告:mysql_select_db() 期望参数 1 为字符串,资源在 E:\Program Files (x86)\wamp\www\Weather-Widget-App-master\PHP\configHome.php 在线 9↵调用堆栈↵#TimeMemoryFunctionLocation↵10.0004244528{main}( )..\weather.php:0↵20.0006248360include( 'E:\Program Files (x86)\wamp\www\Weather-Widget-App-master\PHP\configHome.php' )..\weather.php:2↵30.0300257280http://www.php.net/function.mysql-select-db' target='_new'>mysql_select_db↵( )..\configHome.php: 9↵↵Error selecting 在 mysql 服务器上指定的数据库:“
我的问题是 invalid/depreciated mysql。我用 MYSQLi 重写了我的 MYSQL,然后一切就绪。
我在从我之前 var_dumped 的服务返回 JSON 时遇到了这个问题。呃。希望它对某人有所帮助,因为我浪费了 10 分钟才找到原因。
我在我的项目中使用了以下 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");
}
为了检索 cities/towns 的天气数据。然而,自从我从事这个项目以来已经有一段时间了,我无法理解为什么它不再起作用(上次我 运行 这个项目时它起作用了)。
在浏览器控制台中,我收到以下错误:
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
我包括 dojo 使用:
<script src="//ajax.googleapis.com/ajax/libs/dojo/1.10.4/dojo/dojo.js"></script>
xhr 响应:
"<!--Include Database connections info-->
↵
↵↵( ! ) 已弃用:mysql_connect():mysql 扩展已弃用,将来会被删除:使用 mysqli或 PDO 代替 E:\Program Files (x86)\wamp\www\Weather-Widget-App-master\PHP\configHome.php 行 6↵Call Stack↵#TimeMemoryFunctionLocation↵10.0004244528{main}( )。 .\weather.php:0↵20.0006248360include('E:\Program Files (x86)\wamp\www\Weather-Widget-App-master\PHP\configHome.php')..\weather.php:2↵ 30.0006248936http://www.php.net/function.mysql-connect' target='_new'>mysql_connect↵( )..\configHome.php:6↵↵
↵↵( ! ) 警告:mysql_select_db() 期望参数 1 为字符串,资源在 E:\Program Files (x86)\wamp\www\Weather-Widget-App-master\PHP\configHome.php 在线 9↵调用堆栈↵#TimeMemoryFunctionLocation↵10.0004244528{main}( )..\weather.php:0↵20.0006248360include( 'E:\Program Files (x86)\wamp\www\Weather-Widget-App-master\PHP\configHome.php' )..\weather.php:2↵30.0300257280http://www.php.net/function.mysql-select-db' target='_new'>mysql_select_db↵( )..\configHome.php: 9↵↵Error selecting 在 mysql 服务器上指定的数据库:“
我的问题是 invalid/depreciated mysql。我用 MYSQLi 重写了我的 MYSQL,然后一切就绪。
我在从我之前 var_dumped 的服务返回 JSON 时遇到了这个问题。呃。希望它对某人有所帮助,因为我浪费了 10 分钟才找到原因。