I have The Following Javascript Error "Line 2 Character 1" coming in the entire app I have researched Follwing thing in SOF i have found this link . Javascript Line 1 Syntax error in IE So my JS script is something like this
<script type ="text/javascript">
$(document).ready(function(){
var sv = "<?php ec开发者_如何学JAVAho $var1 ;>";
var sv1 = "<?php echo $var2 ;>";
var sv2 = "<?php echo $var3 ;>";
var sv3 = "<?php echo $var4 ;>";
var sv4 = "<?php echo $var5 ;>";
});
</script>
But when i put the same code under JSLINT it is saying "Problem at line 1 character 2: Expected 'html' and instead saw 'script'." .How can I make by script corrected .Can any one please explain what iam doing wrong
You need to declare html tags first, and THEN you can start typing your script. Wrap it in tags.
You're also having some weird PHP tags there, they need to be finished with ?>, not ;>
You aren't properly closing your PHP tags
<script type ="text/javascript">
$(document).ready(function(){
var sv = "<?php echo $var1 ?>";
var sv1 = "<?php echo $var2 ?>";
var sv2 = "<?php echo $var3 ?>";
var sv3 = "<?php echo $var4 ?>";
var sv4 = "<?php echo $var5 ?>";
});
</script>
Are you sending the PHP directly to the browser? If not, we'll need to see the code as it appears to the browser. If there was a double quote being printed, for example, it would cause syntax errors.
Also, there shouldn't be whitespace between your type attribute and the = character.
精彩评论