javascript - Using HTML Tags in Wordpress Page. Getting Error: "Unexncaught SyntaxError..." -
i retrieving info parse in wordpress page fine. can append names of objects page in wordpress, seek append html tag <h1>
or <p>
, error within chrome console:
uncaught syntaxerror: unexpected token illegal
below code within wordpress page works without errors:
<div id="list1"><h1>beer list</h1></div> <div id="list2"><h1>tap list</h1></div> <script type="text/javascript"> if (typeof jquery != 'undefined') { parse.initialize("", ""); var objs = parse.object.extend("obj"); var query = new parse.query(objs); query.ascending("name"); query.find({ success: function(results) { var obj1string = ''; var obj2string = ''; for(var i=0;i<results.length;i++) { var object = results[i]; obj1string= obj1string +' '+object.get('name')+'</br>'; if(object.get('isobj2') == true){ obj2string = obj2string +' '+object.get('name')+'</br>'; } } jquery( "#list1" ).append( obj1string ); jquery( "#list2" ).append( obj2string ); }, error: function(error) { alert("error: " + error.code + " " + error.message); } }); } </script>
but when add, illustration tag 1 of objstrings, error. i.e.:
obj1string= obj1string +'<h1>'+object.get('name')+'</h1></br>';
here how page rendering, why error happening. seems adding line break when sees tags:
for(var i=0;i<results.length;i++) { var object = results[i]; obj1string= obj1string +' //line break added here <h1>'+object.get('name')+'</h1> <p></br>'; if(object.get('isobj2') == true){ objstring = obj2string +' '+object.get('name')+'</br>'; }
i have see other threads error (i.e. here). not suggestions there work.
any help appreciated, thanks!
i've had similar problem before , fixed making sure html tags in javascript on same line. wordpress template files can read more here http://codex.wordpress.org/page_templates. allow utilize php file template display page.
javascript jquery html wordpress parse.com
No comments:
Post a Comment