我有一个Android应用程序,当我在我的设备中运行并开始查看它时,它会停止并在eclipse的日志中给我这个消息:未检测的syntaxerror意外令牌非法在文件test.html?q = 123: 1
这是文件test.html,它可能有问题:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>my website</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, user-scalable=no">
<meta name="apple-mobile-web-app-capable" content="yes">
<link href="http://www.mysite.com/events-mobile/css/jquery.mobile.structure-1.3.2.css" rel="stylesheet">
<link href="http://www.mysite.com/events-mobile/css/styles.css" rel="stylesheet" />
<script src="http://www.mysite.com/events-mobile/lib/jquery.1.9.1.js"></script>
<script src="http://www.mysite.com/events-mobile/lib/purl.js"></script>
<script>
// all dialog buttons should close their parent dialog
$(".ui-dialog button").on("click", function() {
$("[data-role='dialog']").dialog("close");
});
$(document).on("mobileinit", function(){
$.mobile.defaultPageTransition = "slide";
});
</script>
<script src="http://www.mysite.com/events-mobile/lib/jquery.mobile-1.3.2.min.js"></script>
<style>
#footerTabs {
background: #FFF -webkit-radial-gradient(circle, #FFF, #dee2e4);
}
.ui-listview sup {
font-size: 0.6em;
color: #cc0000;
}
.ui-page, .ui-mobile-viewport {
background: url(http://www.mysite.com/events-mobile/images/tiling_stripes_2.gif) repeat;
}
</style>
</head>
<body>
<div data-role="page" id="eventDetails" data-theme="a">
<div data-role="header" data-position="fixed" data-theme="b" data-tap-toggle="false" style="height: 61px;">
<a href="venuesdnew.html" data-rel="external" data-position="left"><img src="images/back.png" width="48" style="z-index: 9999; position: fixed; left:10px;top: 6px;"/></a>
<div style="margin: 0 auto;width: 150px;left:0;position:absolute;right:0;cursor:pointer;">
<a href="index.html" data-rel="external" style="display:block;background: red;width:160px;height:40px;position:absolute;left:0px;border:none;box-shadow:none;-moz-box-shadow:none;-webkit-box-shadow:none;border-style:none;"><img id="logo" src="images/new-logo.png" width="150" data-position="left">
</a>
</div>
</div>
<div data-role="content">
<div id="eventNameHeadernew">
<h1 id="eventNameTitle" style="color:#151ff8;"></h1>
</div>
<div id="mainContent">
<div class="ui-grid-solo">
<div class="ui-block-anew" id="imageContainer"></div>
</div>
<div class="whiteblock" style="height:auto;overflow:hidden;">
<div class="ui-grid-solo">
<span class="red" style="float:left;color:#151ff8;">Type:</span>
<div class="ui-block-a" id="barinfo" style="float:left;">
<span class="red">Type:</span>
</div>
<div class="ui-block-a" id="clubinfo" style="float:left;">
<span class="red">Type:</span>
</div>
<div class="ui-block-a" id="loungeinfo" style="float:left;">
<span class="red">Type:</span>
</div>
</div>
</div>
<div class="ui-grid-solo">
<div class="ui-block-a" id="genre" style="font-size:13px;"></div>
</div>
<div class="ui-grid-solo">
<div class="ui-block-a" id="hours">
<table cellpadding="0" cellspacing="0" border="0">
<tr>
<td id="Fri" align="right" class="day" style="color:#151ff8;">Fri:</td>
<td class="right" id="friOpen"> </td>
<td id="friCenter" class="center"> </td>
<td id="friClose" class="right"> </td>
</tr>
<tr class="clearrow"></tr>
<tr>
<td id="Sat" align="right" class="day" style="color:#151ff8;">Sat:</td>
<td class="right" id="satOpen"> </td>
<td id="satCenter" class="center"> </td>
<td id="satClose" class="right"> </td>
</tr>
<tr class="clearrow"></tr>
<tr>
<td id="Sun" align="right" class="day" style="color:#151ff8;">Sun:</td>
<td class="right" id="sunOpen"> </td>
<td id="sunCenter" class="center"> </td>
<td id="sunClose" class="right"> </td>
</tr>
<tr class="clearrow"></tr>
<tr>
<td id="Mon" align="right" class="day" style="color:#151ff8;">Mon:</td>
<td class="right" id="monOpen"> </td>
<td id="monCenter" class="center"> </td>
<td id="monClose" class="right"> </td>
</tr>
<tr class="clearrow"></tr>
<tr>
<td id="Tue" align="right" class="day" style="color:#151ff8;">Tue:</td>
<td class="right" id="tueOpen"> </td>
<td id="tueCenter" class="center"> </td>
<td id="tueClose" class="right"> </td>
</tr>
<tr class="clearrow"></tr>
<tr>
<td id="Wed" align="right" class="day" style="color:#151ff8;">Wed:</td>
<td class="right" id="wedOpen"> </td>
<td id="wedCenter" class="center"> </td>
<td id="wedClose" class="right"> </td>
</tr>
<tr class="clearrow"></tr>
<tr>
<td id="Thu" align="right" class="day" style="color:#151ff8;">Thu:</td>
<td class="right" id="thuOpen"> </td>
<td id="thuCenter" class="center"> </td>
<td id="thuClose" class="right"> </td>
</tr>
</table>
</div>
</div>
<div class="ui-grid-solo">
<div class="ui-block-a" id="otherinfo" style="font-weight:bold;"></div></div>
<div class="ui-grid-solo">
<div class="ui-block-a" id="dresscodeinfo" style="font-weight:bold;"></div></div>
<div class="whiteblock" style="font-weight:bold;">
<span class="red"><img src="images/address-icon.jpg" alt=""/></span>
<div class="ui-grid-a" style="padding-top:10px;">
<div class="ui-block-a" id="address"></div><div id="address2"></div><div id="address3"></div><div id="address4"></div><div id="postcode"></div>
<div class="ui-block-b"></div>
</div>
</div>
<div class="whiteblock" style="overflow:hidden;font-weight:bold;">
<span class="red"><img src="images/phone-icon.jpg" style="margin-bottom:5px;" alt=""/><br></span>
<div class="ui-block-a" style="padding-top:2px;">
<div style="clear:both;"></div>
<div class="ui-block-a" id="phone" style="font-weight:bold;"></div>
<div class="ui-block-b"></div>
</div>
</div>
</div>
<br />
<div class="ui-grid-solo">
<div class="ui-block-a" id="directionsButtonContainer"></div>
</div>
</div>
<div data-role="footer" data-position="fixed" data-tap-toggle="false">
<div data-role="navbar" >
<ul>
<li><a href="venuesdnew.html" data-ajax="false" data-rel="page" data-transition="slide" id="venuesNav" data-icon="custom" >Venues!</a></li>
<li><a href="eventsdnew.html" data-ajax="false" data-rel="page" data-transition="slide" id="eventsNav" data-icon="custom">Events!</a></li>
<li><a href="opennowdnew.html" data-ajax="false" data-rel="page" data-transition="slide" id="opennowNav" data-icon="custom">Open Now</a></li>
<li><a href="whatson.html" data-ajax="false" data-rel="page" data-transition="slide" id="myeventsNav" data-icon="custom">What's On</a></li>
<li><a href="news.html" data-ajax="false" data-rel="page" data-transition="slide" id="newsNav" data-icon="custom">News</a></li>
</ul>
</div><!-- /navbar -->
</div><!-- /footer -->
<script src="js/getvenue.js"></script>
<script>
$('#logo').click(function() {
$.mobile.changePage("index.html");
});
</script>
</div>
</body>
</html>
这是js文件:
var imagedir = "http://mymsite.com/apps/events/";
var serviceURL = "http://mymsite.com/services/";
$('#eventDetails').bind('pageshow', function(event) {
var url = $.url(document.location);
var eventid = url.param("id");
console.log(eventid);
function getEventDetails() {
$.ajax({
url: 'http://mymsite.com/geteventdetails.php',
data: 'id=' + eventid,
datatype:"application/json",
type:'get',
cache:false,
success:function(data){
console.log(data);
eventData = $.parseJSON(data);
if(eventData['image'] == ""){eventData['image'] = "thumbnail.png"}
$('#eventNameTitle').html(eventData['name']);
//ANDROID Maps $('#directionsButtonContainer').html('<a type="v" href="geo:0,0?q='+ encodeURIComponent(eventData['postcode']) +'" data-theme="b" data-role="button" id="directionsButton">Directions</a>');
$('#directionsButtonContainer').html('<a href="http://maps.google.co.uk/?daddr='+ encodeURIComponent(eventData['postcode']) +'" data-theme="b" data-role="button" id="directionsButton">Directions</a>');
$('#imageContainer').html('<img id="eventHeaderImage" src="'+ imagedir + "/" + eventData['image'] + '"/>');
$('#genre').html('<div class="whiteblock" style="overflow:hidden;margin-bottom:15px;font-weight:bold;"><span class="red" style="color:#151ff8;">♪</span> ' + eventData['genre'].replace('[', '').replace(']', '').replace(/,/g, ', ').replace(/"/g, '') + ' ' + '') + '</div>';
if(eventData['sunOpen'] == ""){eventData['sunOpen'] = "Closed"}
if(eventData['monOpen'] == ""){eventData['monOpen'] = "Closed"}
if(eventData['tueOpen'] == ""){eventData['tueOpen'] = "Closed"}
if(eventData['wedOpen'] == ""){eventData['wedOpen'] = "Closed"}
if(eventData['thuOpen'] == ""){eventData['thuOpen'] = "Closed"}
if(eventData['friOpen'] == ""){eventData['friOpen'] = "Closed"}
if(eventData['satOpen'] == ""){eventData['satOpen'] = "Closed"}
if(eventData['sunClose'] == ""){eventData['sunClose'] = " "}
else{$('#sunCenter').html(' - ')}
if(eventData['monClose'] == ""){eventData['monClose'] = " "}
else{$('#monCenter').html(' - ')}
if(eventData['tueClose'] == ""){eventData['tueClose'] = " "}
else{$('#tueCenter').html(' - ')}
if(eventData['wedClose'] == ""){eventData['wedClose'] = " "}
else{$('#wedCenter').html(' - ')}
if(eventData['thuClose'] == ""){eventData['thuClose'] = " "}
else{$('#thuCenter').html(' - ')}
if(eventData['friClose'] == ""){eventData['friClose'] = " "}
else{$('#friCenter').html(' - ')}
if(eventData['satClose'] == ""){eventData['satClose'] = " "}
else{$('#satCenter').html(' - ')}
$('#friOpen').html( eventData['friOpen']);
$('#satOpen').html( eventData['satOpen']);
$('#sunOpen').html( eventData['sunOpen']);
$('#monOpen').html( eventData['monOpen']);
$('#tueOpen').html( eventData['tueOpen']);
$('#wedOpen').html( eventData['wedOpen']);
$('#thuOpen').html( eventData['thuOpen']);
$('#friClose').html( eventData['friClose']);
$('#satClose').html( eventData['satClose']);
$('#sunClose').html( eventData['sunClose']);
$('#monClose').html( eventData['monClose']);
$('#tueClose').html( eventData['tueClose']);
$('#wedClose').html( eventData['wedClose']);
$('#thuClose').html( eventData['thuClose']);
$('#address').html( eventData['address']);
$('#address2').html( eventData['address2']);
$('#address3').html( eventData['address3']);
$('#address4').html( eventData['address4']);
$('#postcode').html(eventData['postcode']);
$('#otherinfo').append('<span class="red" style="color:#151ff8;font-weight:bold;">Other Info: </span>', eventData['otherinfo']);
$('#phone').append(eventData['phone']);
$('#dresscodeinfo').html('<span class="red" style="color:#151ff8;padding:0;font-weight:bold;">Dress Code: </span> ' + eventData['dresscode'].replace('[', '').replace(']', '').replace(/,/g, ', ').replace(/"/g, '') + ' ' + '');
$('#barinfo').html('<span class="tags" style="font-weight:bold; text-style:none; padding-left: 7px;">' + eventData['bar'].replace('[', '').replace(']', '').replace(/,/g, ', ').replace(/"/g, '') + ' ' + '');
$('#clubinfo').html('<span class="tags" style="font-weight:bold; text-style:none;padding-left: 7px;">' + eventData['club'].replace('[', '').replace(']', '').replace(/,/g, ', ').replace(/"/g, '') + ' ' + '');
$('#loungeinfo').html('<span class="tags" style="font-weight:bold; text-style:none;padding-left: 7px;">' + eventData['lounge'].replace('[', '').replace(']', '').replace(/,/g, ', ').replace(/"/g, '') + ' ' + '');
$( "#directionsButton" ).buttonMarkup( "refresh" );
}})
};
getEventDetails();
});
所有的PHP页面都运行正常,一切正常。除了那个错误,我不知道erroe在哪里
答案 0 :(得分:0)
您的JavaScript中可能存在语法错误,例如缺少分号。在PC浏览器中打开此网页并检查控制台是否有错误,或使用JavaScript的在线验证工具(http://www.javascriptlint.com/online_lint.php)。
祝你好运。