1

In my HTML file I have the following code at the end:

<script type="text/javascript">
  function voteUp(userID,userName,channelID,messageID,voteUp,voteDown)
  {
    $.get("_vote/vote_ajax.php?userID="+userID+"&userName="+userName+"&channelID="+channelID+"&messageID="+messageID+"&voteUp="+voteUp+"&voteDown="+voteDown, function(response){
       // alert("Data: " + data + "\nStatus: " + status);
       alert(response);
    });
  } 
</script>

But I have error when I load the HTML page:

XML Parsing Error: not well-formed Location: http://localhost/ajaxChat/ Line Number 626, Column 55: $.get("_vote/vote_ajax.php?userID="+userID+"&userName="+userName+"&channelID="+channelID+"&messageID="+messageID+"&voteUp="+voteUp+"&voteDown="+voteDown, function(response){ -------------------------------------------------------------^

If I use only one parameter, the HTML page is loading properly:

<script type="text/javascript">
  function voteUp(userID,userName,channelID,messageID,voteUp,voteDown)
  {
    $.get("_vote/vote_ajax.php?userID="+userID, function(response){
       // alert("Data: " + data + "\nStatus: " + status);
       alert(response);
    });
  } 
</script>
2
  • 1
    What is running the HTML page through an XML parser? Are you actually using XHTML? Commented Sep 28, 2015 at 17:10
  • console.log(userName), what retrieve? Commented Sep 28, 2015 at 17:13

2 Answers 2

2

Your page is running through an XML parser so looks like you need to add a CDATA block

<script type="text/javascript">
/* <![CDATA[ */
  function voteUp(userID,userName,channelID,messageID,voteUp,voteDown) {
    $.get("_vote/vote_ajax.php?userID="+userID+"&userName="+userName+"&channelID="+channelID+"&messageID="+messageID+"&voteUp="+voteUp+"&voteDown="+voteDown, function(response){
       // alert("Data: " + data + "\nStatus: " + status);
       alert(response);
    });
  } 
/* ]]> */
</script>
Sign up to request clarification or add additional context in comments.

1 Comment

It's working! Thank You very much for quick answer.
0

Ok, I've had this problem when using links with multiple parameters in Blogger templates, for example, where they go trough an XML parser.

What you have to do is replace the "&" for "&amp;".

That's it!

 $.get("_vote/vote_ajax.php?userID="+userID+"&amp;userName="+userName+"&amp;channelID="+channelID+"&amp;messageID="+messageID+"&amp;voteUp="+voteUp+"&amp;voteDown="+voteDown, function(response){ ...

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.