未捕获到的SyntaxError:JSON中位置9处的意外令牌A

我有一个地图脚本,用户在其中上下单击,角色在地图上四处移动,口袋妖怪可以显示我的脚本在其他主机上运行,​​但当前主机不在

Uncaught SyntaxError: Unexpected token A in JSON at position 9
    at JSON.parse (<anonymous>)
    at Function.n.parseJSON (jquery.min.js:4)
    at Object.success (map.php?map=2:248)
    at i (jquery.min.js:2)
    at Object.fireWith [as resolveWith] (jquery.min.js:2)
    at z (jquery.min.js:4)
    at XMLHttpRequest.<anonymous> (jquery.min.js:4)
var movements = {

		upleft    : {up: -1, left: -1},

		up        : {up: -1, left:  0},

		upright   : {up: -1, left:  1},

		left      : {up:  0, left: -1},

		right     : {up:  0, left:  1},

		downleft  : {up:  1, left: -1},

		down      : {up:  1, left:  0},

		downright : {up:  1, left:  1},

	};

	

	var x = <?php echo $startX; ?>, y = <?php echo $startY; ?>;

	

	<?php echo $tileArray; ?>

	

	function moveSprite(key) {

		var sprite = document.getElementById('mySprite');

		var newX = x + movements[key]['left'];

		var newY = y + movements[key]['up'];

		

		if (map[newY][newX] == 1) {

			x = newX;

			y = newY;

			sprite.style.left = x*16 + 'px';

			sprite.style.top = (y*16)-4 + 'px';

			

			$("#result").html('<img src="images/loading.gif" />');

			$.get('map_ajax.php?map=<?php echo $map; ?>&x='+x+'&y='+y, function(result) {

				var res = jQuery.parseJSON(result);

				if ( typeof res.name !== "undefined" ) {

					var caught = res.caught == 1 ? ' <img src="images/pb.gif" alt="X" />' : '' ;

					

					var html = '';

					html += '<p>';

					html += '    <img src="images/pokemon/'+res.name+'.png" /><br />';

					html += '    A wild '+res.name+' appered!'+caught+'<br />';

					html += '    Level: '+res.level+'';

					html += '</p>';

					html += '<form action="battle.php" method="post">';

					html += '    <input type="submit" value="Battle!" />';

					html += '</form>';

					

					$("#result").html(html);

				} else if ( typeof res.money !== "undefined" ) {

					$("#result").html('<p>You found $'+res.money+' on the floor!</p>');

				} else {

					$("#result").text('You did not find any Pokemon.');

				}

			});

		}

	}

	

	var users = <?php echo json_encode($usersArray); ?>;

	function addUsersToMap() {

		for (var i=0; i<users.length; i++) {

			var user = users[i];

			

			var image = document.createElement('img');

			image.src = 'images/sprites/'+ user.sprite +'.png';

			image.title = user.username;

			image.style.position = 'absolute';

			image.style.top = ((user.y*16)-4) + 'px';

			image.style.left = (user.x*16) + 'px';

			

			



			$(image).insertAfter('#mySprite');



			

		}

	}

	

	window.addEventListener('load', addUsersToMap, false);

	

	

window.addEventListener('load', function () { addUsersToMap(); startTimer(); }, false);

window.addEventListener('keyup', checkKeysUp, false);

window.addEventListener('keydown', checkKeysDown, false);

这是我的编码我有错误是这条线

var res = jQuery.parseJSON(result);

我固定了

var res = JSON.stringify(result);

但是现在我只是得到你没有找到任何口袋妖怪。它没有触发

if ( typeof res.name !== "undefined" ) {

也得到

Uncaught ReferenceError: checkKeysUp is not defined
    at map.php?map=2:358
init.js:44 Uncaught TypeError: Cannot read property 'innerHTML' of null
    at init.js:44
map.php?map=2:356 Uncaught ReferenceError: startTimer is not defined
    at map.php?map=2:356
评论